I found that the front fog lights are switched on the earth ( -ve) side of the circuit. Quite possibly its the same with the headlight , ie you have a chafed wire or plug that has water in it , allowing the circuit to be grounded and light come on. Have you also checked the plug is correctly attached to the rear of the headlight bulb, its not 180 degrees out or something daft like that?