Sometimes the connector goes causing the switch to overheat and fail. Replacing the switch when this happens is a temporary solution unless you replace the mating connector.
If you can get it to work, leave it on for a while then touch the wires coming out of the connector with your hand. If you feel heat, replace the connector as well. Unplug the connector and look for signs of burning on the electrical sockets or plastic inside the connector. This is a sign the connector is bad. If the contact is bad enough, you may not be ale to get the lights to work.
As mentioned above many people buy a relay kit and use the switch to only pull in the relay. The advantage of this is you do not run the high current the headlights requires through the switch. This current is what causes the connector and switch to fail.