Locomotives, for as long as they were equipped with operating headlights, have always had them on during the daytime.
Diesel engines have always operated with headlights anytime, day or night. When the engine is idling in a yard or stopped at a station, the engineer can set the lights to 'dim'. When the train is ready to proceed out, the lights are switched from 'dim' to 'full'. The lights are never turned off until the engine is shut down.
As far as ditch lights are concerned (here we go!)...
The earliest diesel and electric locomotives (first generation) were not outfitted with ditch lights, as the FRA did not require them. Towards the mid-1970s, select second generation diesel engines were equipped with ditch lights, but still, no FRA regulations required them to be there. However, by the very early 1980s, all diesel engines that were to be kept in active service were mandated by the FRA to have ditch lights. This included all engines being built new, and older engines that had to be retrofitted with them.
Ditch lights (as you now know), are located on the pilot of the engine. They oscillate (flash back and forth) when the engine is moving very slowly (such as when leaving a yard), and when the engine is approaching a grad crossing. Passenger engines must have ditch lights, and they must oscillate when the engine is approaching a station, regardless of whether it's supposed to stop there or not.