Check your lights weekly - it's not unusual to see drivers with just one headlight working who don't seem to realise that they have a problem.
One headlight is dangerous because other drivers might be confused into thinking that there is a motorbike coming towards them on unlit roads - but it becomes even more of a problem if the second light fails.
If your headlights fail you may still have some light from sidelights. If you are following another vehicle you can still follow its tail lights to stay safely on the road while you assess your situation.
Firstly ease off the gas and brake gently, try the dip switch, you might still have full or dip beam available if one or the other fails. The headlight flasher switch might also work if the problem is with the electrical circuitry.
Next, try the light switch - it may be a bad connection in the switch so turn it on and off a a few times to see if anything happens.
If you still have no lights, continue to brake to a halt - if your hazard lights work, use them (or indicators). If it is very dark you might be able to park safely by reversing using the reversing light, brake lights or fog lights. If you have no lights at all get your car off the road or out of the main traffic flow - you will be able to see the other drivers but they probably won't see you.
If you are mechanically minded and have the car's handbook you could check the fuse box - but if you are unsure, leave well alone.
Carrying a torch in the car can be useful to help you diagnose this problem and any other night time issues - but never try to drive using a flashlight, even a high power flashlight.
Stay calm - stay safe!