A light switch has a bimetal strip that acts as a self-resetting circuit breaker so you don't lose the lights entirely like would happen with a blown fuse. The dimmer switch is a good place to start looking for a problem. It lives in a very bad environment- - - -lots of road splash, salt, etc. It can develop a short that will cause the breaker to cycle. Try disconnecting the wires at the headlights one at a time to see if the problem goes away. If not, keep backing up along the wiring, from headlights, to the dimmer switch, to the headlight switch, disconnecting wires until the circuit breaker stops cycling the circuit on and off.
Did you happen to install brighter headlights recently, like halogens or LED's? Some of those types of lights draw enough current to need relays in the circuit to prevent overloading the breaker in the headlight switch.
Jerry