It's the starter switch assembly. Try wiggling the start button and see if the light comes back on. My bike did this and I shot some contact cleaner in the switch (after removing it from the handle bars) and the headlight works again. If this doesn't fix your problem I'd bet you need a new switch assembly. Does the bike live out doors?
Steve in SF
87 Harley FXRS-SP ~ 06 KTM 625 SMC ~ 72 Honda CB750/915cc ~ 92 XR600/654cc ~ 95 XR650l/675cc ~ 03 CRF450r ~ 05 CRF450x ~ 02 XR650l/675cc ~ 86 YZ490 ~ 93 YZ80 ~ 93 XR650l Project