The Casualty Notification Department was a Starfleet department tasked with notifying next-of-kin any time a member of Starfleet was killed in the line of duty.
Despite the Department's existence, James T. Kirk still wrote condolence letters to the families of people killed while under his command. (TOS novel: Allegiance in Exile)