As mentioned...

...check the dimmer switch on the floorboard.

Same thing happened to me... couldn't figure it out, it'd go on/off at random times.

I left work one night jamming to some Waylon Jennings, "Black Rose"... "the devil made me do it the first time, the second time I done it on my own.... " and I noticed my headlights were going on/off in time with the beat of the song... because my boot was smacking the floorboard right next to the dimmer switch. I looked down and looked at the wires... and I said : AH-HA! I gotchu now!!

True story.

-W