Not sure of protocol as this is my first post....
Probably an earthing fault as per other posts, but I have also had weird symptoms due to a faulty brake bulb. When I braked, my headlights came on, but only when the brake bulb was cold. Once I had braked a few times, and the bulb was up to temp, it worked fine....
Until it cooled down again.
It may be worth replacing the bulbs one by one and re-testing. For my problem, I replaced the light housing, re-earthed, prayed to the Land Rover Gods and it still didn't work. Until I swapped the brake bulbs.....
If you go with earthing as the issue, I would install temp earths one by one to try to identify if there is a single faulty cable etc.