Headlights go on and off when engine is hot

If the terminals are getting hot and melting the connector/insulator, why?

I'd find the issue causing the problem. Melted connectors are a symptom.

Relays are a great solution to the headlight performance and switch issue. Part of the reason I started building kits.