Shooting from the hip as electricity is funny.
1. Also, check all of the fuses in the underhood junction box. Check all for the correct amperage per the chart on the covers.
2. Check all bulbs for proper specified bulbs.
3. Check for a short. Are the bulb connections corroded or touching an inadvertent wire or the body of the car.
4. Does the 540 have a brake light switch? Check Bentley.
5. All of that fails - you can take your electric diagrams, multi-meter and a highlighter and start testing.
6. Might be a short in the LKM (Light Control Module). On my E34 it does control all lights, not just the headlights. It is in the Underhood junction box. It may also be loose.
7. Could be the wire connection to the fuse box.
As I said electricity is funny. Hopefully this is a common issue that a 540 owner will respond.