Headlights not always working

You've noticed that...

The headlights don't always switch on after pressing the headlights on the button or stalk in the car. Occasionally the headlights will go off and need switching on and off a few times to get them back on again.
This 1 part can be connected to or cause the problem