If both headlights are going out and coming back on but all the others are working, as already suggested check the dimmer switch. If you are using halogen bulbs then you might want to consider installing relays to the bulbs to take the load off the dimmer switch and headlight switch.