The headlight switch has an internal breaker. It's getting hot and breaking the connection. When it cools off, your headlights come back on. If you're running aftermarket headlights, they're probably drawing more current than stock, and flipping the breaker. The permanent fix is a relay kit.