Most modern vehicles have inbuilt headlight alarms or automatic headlight switch off functions. Older vehicles do not have these features and can have a flat battery if the headlights are left on when the vehicle is turned off.
There are many headlight alarm systems available ranging from simple to complex & expensive. Shown below is a very simple method to sound a buzzer if the ignition is turned off while the headlights are turned on. All that is required is an automotive change-over relay and a buzzer. The diagram shows the relay pins as viewed from the pin end of the relay.
(If preferred, the headlight power connection could be connected to park light power instead, which will alarm if headlights or park lights are left on).