To check if the headlight switch is causing the problem, try turning the switch to the "Off" position and then back on again. If the headlights turn off when you do this, then the headlight switch is faulty and needs to be replaced.
Here are some additional things to check if your headlights are staying on after the ignition is turned off:
* Check the headlight relay. The headlight relay is a small electrical component that controls the power supply to the headlights. If the headlight relay is faulty, it may not turn off the headlights when the ignition is turned off. To check the headlight relay, locate it in the fuse box and swap it with another relay of the same type. If the headlights turn off when you do this, then the headlight relay is faulty and needs to be replaced.
* Check the wiring. If the headlight switch and the headlight relay are both functioning properly, then the problem may be with the wiring. Check the wiring for any loose connections or breaks, especially around the headlight switch and the headlight relay. If you find any loose connections or breaks, repair them and see if that solves the problem.
If you are not comfortable checking the headlight switch, headlight relay, or wiring yourself, you can take your vehicle to a qualified mechanic to have it diagnosed and repaired.