I am not an electrician but I know it's simple for electrician than me. I would like to rewire my headlights turn off whenever the ignition off. The reason I want this because my wife usually forget to turn off and the battery drain down.
Short Version:
1. Learn what a relay is. http://www.the12volt.com/relays/relays.asp
2. Get one, and hook it up to the ignition wire and the wire coming from the healight switch.
Long Version:
Hook up a wire that shows +12v when the ingnition is on to pole #85 on your SPDT relay. You then hook up #86 to ground. Next find the wire running from your healight switch to the cars built in headlight relay. (I don't know where this relay is, sorry. You can hear it click when you turn on the headlights though.) Cut this (scary, I know) and connect the switch end to #87a and the car relay end to #30. This will do what your asking in your post.
BUT!!! I don't know what it will do with your parking lights. With this setup they will probably stay on. You could solve that by using two relays though. Anyways I'm sure there are others on this forum who can give you a more comprehensive guide. Mostly I recomend looking at www.the12volt.com to learn about relays and then find out exactely how the lights are wired in our cars before doing anything.