Under the left hand side cover (as sitting on bike your left) the middle relay is the one, give it a tap when you have the symptom and see if the lights go out. If they do go out the chances are that is the cause. Just unplug it and find a replacement, either after market or OEM.
Looks like it could be ignition switch or plug, you can pull the bottom off the switch and check the solder joints. If this is the problem fit relays to the headlights to stop it happening again.
Looks like it could be ignition switch or plug, you can pull the bottom off the switch and check the solder joints. If this is the problem fit relays to the headlights to stop it happening again.