You might want to check your starter relay. It not only powers the starter solenoid, it control the headlights during startup. When you push the starter button, the contacts for the headlight open (turning light off) until you release the button. If the normally closed contacts for the headlight in this relay are corroded, it's time to clean them or change the relay. Next time your headlight doesn't light up, tap the relay under the tank on the right side.