Most likely you have a wire which has rubbed through the insulation where it goes into the back of the headlight housing. The wiring harness has been known to chafe at this location, and it is a matter of carefully pulling the loom out and looking for bare spots. I find electrician's tape to be a pain to use in wire bundles, so I use this:

You can find it at most hardware stores. It is also great for treating the ends of bootlaces so they don't fray.