Misty Terrain will activate as soon as a Pokémon with Misty Surge enters the battle, and it will linger for about five turns, regardless if it faints or gets switched back.