David is a subversion, as the heroes are the ones that mete out his karmic punishment rather than the villains he threatened to betray them to.
Chapman, as a teenager, tries to offer the human race to the Yeerks in order to save himself, which is ultimately what starts the invasion and leads to his own infestation.
Subverted later in life, though, as Chapman and his wife (also a Controller) offer their services in order to keep their daughter safe. The Yeerks agree.
Averted in Tom Clancy novels, the American and Soviet characters make it clear that defectors must be rewarded and protected in order to encourage other defectors. It is part of the unwritten rules of espionage. Furthermore, assassination of a defector is a violation of the unwritten rules and even kidnapping a defector can be punished with death for the kidnapper. The espionage game is supposed to be civilized. The rules are more gray/grey when applied to proxy wars.
Star Wars Force Commander: After proving their loyalty in combat, Tyr Taskeen allows several imperials to join the Rebellion as trusted officers. This is common in the Star Wars universe; defectors are only executed if discovered before they actually defect. Their new superiors trust them after a heroic action or the revealing of top-secret information.
Justified since a majority of the Alliance leadership and many of its most famous heroes are Imperial defectors. It also helps that the vast majority of Imperial defectors tend to be Punch Clock Villains who only switch sides when they realize how bad the Empire is.
In J. R. R. Tolkien's The Silmarillion, Sauron tells his captive Gorlim that he will be reunited with his wife Eilinel (apparently captured by Sauron) if Gorlim reveals where the heroes are. Gorlim gives in, at which point Sauron reveals that Eilinel is already dead—and Sauron does, indeed, reunite Gorlim with her.
In Dune, Dr. Wellington Yueh betrays the House Atreides for the sake of freeing Wanna from Harkonnen tortures. Yueh is an interesting case in that he walks into it with his eyes mostly open — he strongly suspects that Wanna has been Released to Elsewhere and is betraying everyone just to get close enough to the Baron to kill him in retaliation. He knows he'll only be killed for his troubles once he's outlived his usefulness, and while he does deliver the Duke Atreides to the Harkonnens he does ensure that his consort and son escape, and replaces one of the Duke's teeth with a poison gas capsule for killing the Baron. Sadly for him, subsequent history remembers him as worse than Judas and for thousands of years his name serves as a byword for unconscionable treachery.
"You think... you have defeated me? You think I did not know... what I bought... for my Wanna?"
Combined with False Reassurance in The Three Musketeers. One treacherous character gets rewarded for aiding Cardinal Richelieu and has the bad judgment to "remind the Cardinal he is still alive" with what is presumably a letter begging for money. The Cardinal's response is that he will "take care of him for the rest of his life". The reader is informed a page later that the guy disappeared one day and is assumed to have spent the rest of his life "secure" in a castle with all of his meals provided. The character appears again, much transformed, in the sequel. Exactly what he went through is not clear, although it's unlikely Richelieu really cared what happened to him.
In the Susan Cooper novel The Dark Is Rising, Merriman Lyon's servant Hawkin betrays him and goes over to the Dark. At the end of the novel, the Dark callously throws him down from a great height, severely injuring him.
In the Novelsofthe Jaran, a chapalli turns traitor to his leader and swears allegience to the human Tess Soerensen. Some time later he betrays Tess to his leader: when all three confront each other, the leader kills his traitorous subordinate, and apologises to Tess for the shameful behaviour of his subordinate in betraying her having pledged allegience to her.
Romance of the Three Kingdoms plays this trope straight and averts it in some instances: Good civil servants and military officers were in need, after all. Several officers that would become practically synonymous with one of the Three Kingdoms started out fighting that kingdom (Zhang He, Zhang Liao, Taishi Ci, Gan Ning, Ma Chao, and Huang Zhong to name a few) and none were thought any less honourable for having switched sides. They however, usually changed allegiance after their lord was dead or surrendered and most of them went over openly. Most backstabbers and people who actively betray their lords feel the wrath of this trope:
When Lu Bu begged for his life, Liu Bei reminded Cao Cao that Lu Bu had already betrayed three people at that point (making him almost an aversion: his first three treasons were heavily rewarded), two of whom he had killed, and the third being Liu Bei himself. In the novel they contrast this with Zhang Liao, who mocked Cao Cao and was prepared to die, until Guan Yu and Liu Bei begged Cao Cao to spare him. Since he was an honorable warrior, Cao Cao agreed and Zhang Liao became one of his greatest generals.
Miao Ze: I desire no reward, only Chunxiang for a wife.
Cao Cao: For the sake of a woman, you destroyed your brother's entire family. A man so faithless does not deserve to live.
Yang Song was an officer of Zhang Lu that received several bribes from multiple sides. When his lord surrendered to Wei, Zhang Lu and most of Zhang's surviving officers and officials were given positions in Cao Cao's administration. Yang Song was passed over, and when he went to Cao to complain, Cao had him executed.
Wei Yan was also one of the most notorious traitors in the novel (having betrayed Liu Zong, and then Han Xuan in attempts to go over to Liu Bei's side), but he both fits the trope and subverts it, depending on who he is serving at the time. Liu Bei tends to deliberately overlook Wei Yan's faults after Wei Yan joined him and, as a result, Wei Yan remains loyal to him; Zhuge Liang has a vehement dislike of Wei Yan ever since he joined, however, and after Zhuge Liang's death, Wei Yan plays true to form and attempts rebellion. Zhuge Liang, who has foreseen Wei Yan would do so, promptly plots with Ma Dai to incite Wei Yan to rebelling and then has Wei Yan killed for it.
In Mercedes Lackey and Andre Norton's The Elvenbane, a wizard decides that the rebellion against the elven overlords is doomed to failure and attempts to buy his survival by offering his services and his knowledge of the rebels' secrets to an elvenlord. The elvenlord smiles encouragingly, listens to him carefully, and then tortures him to be sure he wasn't lying and finally reduces the man to ashes when he's done.
Averted quite notably in Victory of Eagles: Napoleon's offer in the last book of sanctuary for Laurence and Temeraire ("I will not insult you with offers of treasure"), or barring that free passage to China, in return for the plague cure was at least in part a coldly logical tactic for keeping the bloodline of the Chinese Celestial breed away from the British. However, during increasingly violent foraging raids from occupied London, despite the fact that both Laurence and Temeraire were both serving the British once more, Laurence's family estate remained untouched apparently out of nothing more than sheer gratitude.
Done with a twist, in This Rough Magic by Mercedes Lackey, Eric Flint, and Dave Freer. The Hungarians threaten a man's son in order to get him to give the location of some heroes. The man does this and finds his son has been killed anyway, but then the heroes help the man to escape with his life and tell him to go tell everyone about this, which creates bad publicity for the Hungarians and helps the heroes defeat them in the end.
In Barrayar, Cordelia walked in on a conference where two of Vordarian's men were trying to sell him out. This was no longer possible, of course, because she had Vordarian's severed head in the shopping bag she was carrying, but she advised them to throw themselves unconditionally on Lord Vorkosigan's mercy, adding, "He may still have some." Although she didn't speak the words, "I certainly don't," everyone in the room heard them.
Littlefinger does this in A Song of Ice and Fire, having the man who helped sneak Sansa out turned into a human pin-cushion as soon as his job was done.
The Small Council in A Feast for Crows suggest doing this to House Frey after their horrific betrayal of House Stark/Tully in the Red Wedding, but Cersei just tells them to let them be, considering that Walder Frey is very old and is likely to die soon.
The first, however, is a combination of He Knows Too Much and You Have Outlived Your Usefulness with the standard Traitor's Reward cited as either an explanation or an excuse. By contrast, the Small Council is actively seeking to publicly distance itself politically from an atrocity committed with their secret approval and tacit encouragement. The only person who expresses distaste for such a den of traitors is Jaime Lannister when confronting Lady Spicer, and he still sticks to his father's agreement to reward her with titles and good marriages for her family (though decidedly not quite the ones she was hoping for). So, this is also an aversion of this trope after nodding at it. A Lannister, after all, pays his debts... even while twisting his top lip in distaste. However Jaime's cousin Ser Daven Lannister also shows distaste for the Freys, wishing that some of those under his command would die, though notably finds a few decent (the ones that didn't take part in the Red Wedding).
Historically, as detailed in "The World of Ice and Fire", this happened at the end of "The Dance of the Dragons", a Targaryen civil war. As Cregan Stark approached King's Landing with his army, Aegon II was poisoned before he could harm his nephew, who succeeded as Aegon III. Even though Cregan had been fighting against Aegon II, he still had their murderers executed or sending them to the Wall (though pardoned Corlys Velaryon), as he believed a King's murder should be punished.
King David was fighting a civil war against King Saul's successor, Ish-Bosheth, and two opportunistic officers assassinated the enemy king and presented his head to David in anticipation of a reward. He executed the traitors, cut off their hands and feet, and hung their corpses up by the pool at Hebron as a warning to others. As for Ish-Bosheth, David ordered him buried with full honors. This is also in keeping with how he treated an Amalekite who came bringing his predecessor Saul's crown and armband, claiming to have done a mercy-killing on Saul himself. Although David presumably found out later (after executing him) that the man was lying, he cited his decision concerning this other man to Ish-Bosheth's murderers, pointing out that what they'd done was far worse.
The Bible also has two aversions. The first one: Balaam showed his loyalty to Yahweh even though his life was at risk and blessed the Israelites rather than cursing them as God told him to. He was killed for trying to have it both ways. He wouldn't betray God by pronouncing a curse where a blessing was required, but he still wanted the reward that the Midianites were offering to him. So he taught them how they could turn the Israelites away from the commandments of God and bring His curse upon themselves, making him a pretty straight example of this trope.
Second one: The prostitute Rahab gave aid and comfort to two Israelite spies, allowing them to bring back information that allowed them to annihilate Jericho. Joshua spared her, and she became one of the ancestors of Christ! note Rahab married Salmon and became the mother of Boaz (Matthew 1:5) from who David's paternal family came.
In Artemis Fowl, Mulch attempts to sweet talk some goblins by claiming he doesn't approve of the dwarf/goblin tunnel wars and is actually a goblin sympathiser. In response, the goblins attempt to kill him; the only thing they hate more than a dwarf is a traitor to his own kind, and Mulch ticks both boxes.
In the Iliad, Dolon was captured by Odysseus and Diomedes and interrogated. To save his life, he quickly tells everything he knows. Then Diomedes kills him for speaking too easily.
In the Redwall series book Mattimeo, Slagar adds a defecting shrew to his chain gang of slaves after the shrew volunteers useful information.
Slagar is a double-crosser anyway, promising his slaver recruits the sky only to abandon those who haven't died along the way and pit them against each other.
Badrang in Martin the Warrior does this.
Subverted by Tsarmina in Mossflower, who states that not invoking this trope is the only reward for defecting to her side.
A spy in The Bellmaker is warned about this by Urgan Nagru, the Big Bad, after he offers information on Nagru's mate (they're constantly plotting against each other) after the rat suggests a reward would be in order. He's then happy to escape with his life.
In The Dresden Files, the Winter Knight Lloyd Slate betrayed Mab, and the way she punished him was... excessive. She entombed him in ice, crucified on a tree of the same, until he's almost dead from frostbite and exhaustion... at which point Mab takes him out, feeds him, heals him, and takes him to bed with her, only to return him to his torture when he wakes up. Never piss off the queen of The Fair Folk, people.
Mab: To be sure, the White Christ never suffered so long or terribly as did this traitor. Three days on a tree. Hardly enough time for a prelude. When it came to visiting agony, the Romans were hobbyists.
Averted with Harry himself: when he tried to cheat Mab of her Knight, she was not only amused and proud, but she risked reality itself by spending six months healing him. Justified Mab knew Harry well enough to know that he would try to find a way out, and he was not betraying her to someone else, he was being a Rules Lawyer about their bargain- which is actually something Mab wants in a Knight, as she's looking for someone who can survive Faerie politics and be something more than your average Winter thug. By weaseling out of their bargain like he did, Harry showed that he was clever enough to almost cheat the Winter Queen, had enough moral fiber and determination to resist the Winter Knight's mantle, was independent enough to create his own plans and execute them without her micromanagement, and was cheeky enough to question her if need be. Harry actually gets her to back down on controlling him by threatening to not show these qualities- if she tries to control him, he'll go Literal Genie on her and force her to spend all her time pushing him places if she wants anything done.
In Repairman Jack novel By the Sword Yakuza interrogate a local mook by threatening to cut off his pinky. The man caves in and gives the information. Then Yakuza cut off the finger and swallow it (to prevent re-attachment) for ratting on a friend.
The Stand: Randall Flagg, using a few different methods of persuasion, manages to convince Harold Lauder to try and destroy the good guys' governing committee, post-apocalyptic plague. Lauder sets off the bomb and heads out to join Flagg's burgeoning army in Las Vegas. However, Flagg arranges for Harold's death on the way, and Flagg's surrogate basically says, "Once a betrayer, always a betrayer."
Septimus Heap: When Simon has told the Supreme Custodian about the location of Zelda's cottage, the Supreme Custodian plans to kill Simon along with the other Heaps.
Averted, surprisingly enough, in The Prince. Machiavelli expounds on how this Trope is actually bad practice. Any advantage the Prince can cultivate against his enemies is a welcome one, and if there are people working for his enemies that are willing to turn on them, they should be encouraged, and then fairly rewarded if said betrayal works to the Prince's favor. The Prince is essentially gaining an ally in the traitor, and someone who punishes his allies for helping him will soon find himself without any.
Averted in The Legendsong Saga when Glynn is rescued by myrmidons on Fomhika. Instinctively trusting her, they take her back to the inn where several Darkfall allies have gathered and, despite her attempts to leave, offer her the chance to join them. Hella then reveals that Glynn is working for the Drakka and they realise she now knows too much, but they offer her the chance to spy on the Drakka for them instead. Glynn is tempted to take their offered escape, but her sense of honour forces her to refuse. Duran is impressed, and reveals that if she had accepted she would have allowed one of the other myrmidons to kill her. Instead she lets her go, offering friendship and requesting that Glynn reconsiders about her loyalties.
The Maurice Ogden poem The Hangman tells the story of a traveling hangman who comes into a quiet town and builds a gallows, telling the citizens that he has come to execute the one who "serves me best". He begins hanging random citizens under the pretense that he has to make sure the gallows are still functioning, and the populace are either too indifferent to help or too afraid that they will be next if they intervene. Eventually, the narrator is the only person left in town, and when the Hangman comes to him, he explains that the narrator was the one he came to hang, as his willingness to let the Hangman murder an entire town in the naive hope that he would be spared makes him the Hangman's most faithful servant.
In Undefeated Bahamut Chronicle, Listelka offers to spare the Seven Dragon Paladins if they join her. Magialca and Singlen quickly do so, only for Listelka to say that they will be executed, as she can't trust people who switch sides so easily. In a twist, Magialca and Singlen weren't trying to surrender; rather, their true aim was to make Lux (another Paladin) appear to be a better option as a collaborator. This succeeds and kicks off a chain of events that leads to Aeril (Listelka's sister) betraying her family and all of the Paladins escaping. The trope is then subverted when Aeril is allowed to live despite being a traitor to her family.
Peter Pettigrew in Harry Potter. He betrayed the Potters in hopes of being famous as Voldemort's Dragon, but instead it led to him being forced to go on the run and live as a common animal. Even when he gets the chance to revive Voldemort and resume his position, he has pretty much nothing to offer Voldemort except as The Igor when he's at his lowest point, and they both know it. He spends the rest of the books in the background as Voldemort's contemptable, abused servant. His death is also a classic example of the trope- Voldemort programmed the silver hand he gave Wormtail to strangle him if he ever betrayed Voldemort, because Voldy knew that he would do so in an instant if provided with a better option. Wormtail never really got that option, but his moment of hesitation in killing Harry was interpreted as betrayal and he got strangled by Voldemort's gift to him.