This happens to me often, except the camera gets stuck in the unlocked position and doesn't return even when the centering key is pressed or held. The first time, I reset my client and reconnected to the game because I didn't know what else to do. After getting impatient and nervous of that method, I started toying around with other things and noticed that either changing the camera mode to something else, then back to the preferred setting usually fixes it, and if that does not, simply changing anything in the Video settings does (because it literally resets the screen, to regenerate the rendered graphics). Alt-tabbing out works too but I'm not sure which method is the shortest, since they all take time that can be costly in the middle of a game, but hopefully that helps.