It does that becaue teh circut breaker is kicking the off an don so you don't burn your truck up. Disconnect the dimmer switch onthe floor and turn headlights on and see if stops. If it doesn't then you have a wire touching ground someplace, in otherwords shorting out. If it does stop it by disconnecting the dimmer switch, then replace the switch, it's on the floor. They get water and corrode causing that alot of times.