If you have auto card switch enabled, it'll switch as soon as you close the door. So, either turn off auto switch or don't close the door until after you've already put the card back.
And, yes. It'll do the switch even if the camera is off when you take the card out, but only if you close the door with an empty slot.
b&