I'd like to add another perspective to this issue...
I've ran a game where 1 of the PCs was a traitor, and it worked well story-wise. This character didn't kill any of the other PCs, but made the task harder (& the PCs lives a bit more interesting).
Now, this was for a Heroes Unlimited campaign, so I can't really say if the type of game/setting may have made a difference.
The player in question played in 2 groups that I DMed for. In 1 group, he played a good character; since he was playing w/ another group as well, I gave him the option of having either his old character or the new one to play the part of a traitor (spying on the PCs & reporting to the enemy--if things got bad or the character was found out, then the double-agent could do what was necessary to escape &/or hinder the other PCs). He went with the idea (& it was the only time I allowed an evil-aligned PC).
It worked well. The other PCs/players despised the character (but not the player), & the character became infamous--about as memorable as a few other villains of mine.
Now, as for using this tactic in a D&D game, I'd say that it could work, but only at the right moment. If the other PCs gain means to detemine the character's true agenda, than provide the character with a means to evade it. Also, I think that it's best to have this PC work subtly rather than overtly--there's a few more ambushes along the way, the villains seem a bit more aware of the party's resources, the PCs are misinformed about an opponent, have less resources than they thought they began with, etc.
The PC's treachery should only be immediately evident when it is, for lack of a better word, the cinematically best time for the turn (e.g., tipping the odds in the villains' favor), or when/if the PCs discover the character's treachery--in either case, the PC should then become an NPC afterward (perhaps allowing the PC to play the moment of the turn, but nothing afterward). The former PC could die after the turn, or he/she could escape & take the role of a recurring villain.
However, the player should have a new character/option immediately available after the turn--you may want to have an NPC (which is actually the player's replacement character) accompany the PCs, and then have the player assume the NPC's role after the traitor is revealed. You may want to have a few other NPCs available either as replacement characters (if any other PCs die after the turn), or as victims of the traitor's machinations (a good friend, valued companion, lover, etc.--i.e., a character with an emotional/personal attachment to the PCs).
Also, as a DM, I'd caution that it's very important to be picky about who you allow/have to play this role. I think it works well with an experienced player who you think is capable of playing the role intelligently, is able to keep things secret (i.e., not blurt out, brag, or (in)advertantly drop hints about it), and whose capable (& ideally, willing) of playing/resuming a good guy role afterward (having that player play a selfish, scheming, or other questionable character after the traitor PC may maintain the other players' feelings of distrust, but they may be directed toward the player instead of just the character). And, it should come from a player who the other players wouldn't expect such behavior from--it's not as surprising if it comes from a player who often plays conniving/selfish characters.
And, to be honest, it's not a good idea to use this plot device (which is what I see this idea as) in a group that has players/characters who already act in a disruptive, selfish, or similar manner. Also, it's a one-time plot device--don't use it in more than 1 game with the same group of players (or, at least do it years apart in different genre games).
Just my 2 cents on the matter.