Depends on the Railroad... the FRA does mandate Ditch Lights, but leaves it up to the RR as to whether they flash, and if so, when they flash (some only flash at crossings or in yards but are on steady when out on the road).
I have seen two types. Some are always on steady (mostly UP engines, in my experience), while the rest flash for 30 seconds after the horn is blown. On most current production locomotives, the ditch lights come on automatically whenever the headlights are on bright, and also whenever the horn is blown. Some older Conrail locomotives have a separate switch for the ditch lights, though they will still flash after blowing the horn.