How many times has that happened?
No idea, but it has happened (as told to me by retired Navy guys). Basically, the CO is responsible for everything that happens on/to the ship, and if the crew steers into a pier or whatnot that means it's the CO who gets it. There are plenty of officers who rate a command and never enough ships, so there's no reason to be lenient or forgiving of cock-ups, and it forces the COs to really pay attention and make sure their crews are on the ball and everything is ship-shape. Even when they do great, most COs command one ship for maybe a year or so. They don't stay with the same vessel or crew for years on end. Rotation is the name of the game.