Exactly, sorry for not making that clear. He didn't surrender just the Navy.Adm. Donitz was, briefly, the president of Germany. Technically it was in that capacity he arranged the surrender, not as a military commander.
He ended up in charge because the upper ranks of the Nazi Party civilian leadership were either fleeing or unwilling to surrender. It's one of the better examples in history of trying to play The Big Lie all the way to the end.