There are usually two different types of effects like this. The first one is in the case of Raichu, the effect is on Raichu himself. So if you were to KO something, or they retreat their Pokemon the effect remains on Raichu. The other is something like Sand Attack, where the effect is on the Defending Pokemon. If the Defending retreats, switches, gets KOed, or evolves then the effect goes away.
Another example of this is the Mothim from Secret Wonders. Its attack Silver Wind says that all attacks deal 40 more damage to the DEFENDING Pokemon. So as long as the same Pokemon that your opponet had out last turn is still in the active posistion, you deal the extra 40 damage. Also, Mothim doesnt have to me the one to deal this damage either, it could be any of your Pokemon because the effect is on the Defending Pokemon, not Mothim.
Hope it clears up any confusion.