Off again on again does sound more like a connection issue or a bad wire. The bad ground is a possibility. Start at the FCM connector and work your way to the headlight connector.
Get the FSM here > https://www.cumminsforum.com/forum/3rd-gen-powertrain/1909713-newbies-guide-your-new-you-truck.html
IIRC section 8 is the wiring.
Get the FSM here > https://www.cumminsforum.com/forum/3rd-gen-powertrain/1909713-newbies-guide-your-new-you-truck.html
IIRC section 8 is the wiring.