In my U.S. Navy experience (submarine force), the in-port officer that was on-duty and in charge of the ship in the CO’s absence was referred to as the Ship’s Duty Officer (SDO).
As previously noted, the SDO was also a qualified Officer of the Deck (OOD), and thus qualified to take the boat to sea.
The term “Command Duty Officer” (CDO) was a more generic term that was generally used only for shore commands. For example, the shore-based submarine squadron I was later assigned to had a daily CDO.
–robby (former qualified submarine OOD/SDO & sub squadron CDO)
It should also be noted that the position of SDO/CDO is a watch station, not a billet (i.e. job).
In other words, a duty officer stands the watch for a certain period of time (usually 24 hours), and his/her movement is limited. For example, when I stood watch as SDO on a submarine tied to the pier, I was limited to the pier. If I needed to go anywhere else, I needed to get someone to relieve me. When I stood watch as a squadron CDO, I was limited to the confines of the Navy base. This meant that when I stood watch as SDO, I didn’t go home that night. Instead, I slept on the boat. When I stood watch as CDO, I slept in the CDO bunkroom at squadron HQ.
The position of XO (Executive Officer) mentioned in Post #7 is different. It’s a billet (i.e. job) that an officer is assigned to for a much longer period of time (typically 2-3 years). The XO (and CO, for that matter) can go home at night when the ship is in port.