Pokémon Black Version and Pokémon White Version - Switching Upon Fainting
A Pokémon is not changed to a different one immediately after it faints, but rather at the very end of the turn, after all end-of-turn effects. Some exceptions are mentioned in the list of moves using wording like "The new Pokémon enters the battle immediately."
{In Single Battles as well as Double Battles, if a Pokémon faints during its attack segment, the other Pokémon can still take their attack segment if they haven’t done so already.}