When that happens, Sgt get promoted then.
Officers do take hit in battle too, they're rarely shown but it happens often. At GAC, my captain collasped due to heatstroke, First Sergeant took over the company and led us through the Wheatfield.
Historically, after the battle, company will have election to get a new captain. During the battle, Jr officer or senior NCO takes over.