basically a relay is as witch controled by a seperate voltage. so if you wired in so the voltage to the headlights stwitched it you could run the power to the lights through it.
depending how you wire a relay, it can either turn the switch on /w a voltage or turn it off.