i think earthing for your headlight is corroded. You should find the contact and clean it. If you have a battey contact protective spray, use it.
alternatively, you can bypass the earthing by adding a wire.
Whichever you do, you have to make a good earthing connection. Otherwise it keep...