I had a similar occurance that you described, it happened after I washed the bike, I blew out the starter switch with compressed air, and it never came back.
If your headlight goes out when this happens, the lighting relay is de-energized when the starter is activated by the start switch and starter relay.