No. A Pokémon does not need to be the one to finish the battle to gain EVs. It at least needs to gain experience in battle. So if it is too weak in battle, just switch train it, which is just sending your weak Pokémon that needs the EVs, and switch out to another Pokémon that is able to battle, and finish the opposing Pokémon off to gain EVs to the desired Pokémon, or, just pop an EXP. Share on it. Or if it is capable of battling you can just go ahead and finish the foe off. This is really helpful for EVs training weak Pokémon. So, at least the Pokémon has gained experience in the battle, it will gain the EVs that the foe provides it!
I hope this helped!