>In the turn that Yawn is used, the only effect will be the user yawning at the target. At the end of the next turn, the target (if still active) will fall asleep unless it gets affected by a major status condition in the meantime, a status-protecting move is used (like Uproar), or the battle ends.
-Bulbapedia
>Takes effect at end of the next turn after use. If the afflicted switches, the move does not take effect.
-Other Bulbapedia
Yawn's effect wears out if you switch out. This makes moves like Spore better in some situations.
Source: Above links and own experience