The Radix: The Knight's plans of becoming the leader of the Knights of Malta was foiled not by heroes, but by a mere bum who recognized him as his pal's abductor and reported to authorities.
Gríma Wormtongue of J. R. R. Tolkien's The Lord of the Rings turned on Saruman after one taunt and demand too many — and after Frodo had deliberately spared both their lives and ordered the other hobbits to do the same.
The aforementioned hobbits stuck Gríma full of arrows as soon as he killed Saruman and started his escape, most likely as payback for Wormtongue's murder of Lotho Sackville-Baggins, Frodo's kinsman and fellow accomplice. Either that, or they (correctly) figured a person who stabs someone in the back isn't someone you want running around your homes.
Note that this karmic death was apparently so appealing that even though the entire section leading up to it was left out of the movie, the back-stab was transplanted onto Saruman's Tower. Gríma is similarly killed by the heroes, possibly to keep him from killing Saruman, just a second too late.
At the end of Tigana, one wizard Evil Overlord is killed by his own court jester, an old enemy kept idiotic by spells, which had failed.
In Robert A. Heinlein's If This Goes On... the Prophet dies in the gap between when the women at his headquarters realize he will lose and the actual arrival of enemy forces.
The Belisarius Series. The good guys are triumphant, but the evil Malwa emperor and the real Big Bad have escaped with the Big Bad plotting how to try again...only for the emperor to be recognized and the pair captured by a team of Malwa assassins who've spent the entire book helplessly trying to catch their target, the Roman Emperor, had given up and were trying to find somewhere to hide from the new regime. Until they recognize an opportunity to make a nice payday for capturing a wanted man.
Subverted in Isaac Asimov's Foundation trilogy: Cornered by the Mule, an agent of the Second Foundation frees a Brainwashed victim and points out there is no way he can both stop the agent and keep his victim from killing him. When the Mule agrees to his terms, the agent allows him to Brainwash the victim again.
In C. S. Lewis's Prince Caspian, Miraz is baited into fighting a duel with Peter by the noblemen Glozelle and Sopesian, and he calls them cowards for trying to get him to refuse. When Miraz falls in the duel, Glozelle stabs him where he lies, supposedly for the insult (though he and Sopesian had been hoping Miraz would die from the beginning).
At the end of the Redwall book Lord Brocktree, Ungatt Trunn, his back broken, lies helpless on the shore, the tide about to pull him out to sea. As another animal comes up to him, he begs for help... but then realizes it's his former fortune-teller, the fox Groddil, whom Trunn had crippled and routinely mocked. Groddil shoves him into the sea and gives one last mocking proclamation as Trunn drifts hopelessly away.
Redwall example #2: In Mattimeo, Malkariss is killed by the slaves he had forced to build his kingdom.
Redwall example #4: Captain Slipp kills the badger mother Mellus, steals a silver cup, and flees. Blaggut, his ex-bosun, follows him, but cries his eyes out all night because he liked Mellus and he wanted to settle in the Abbey. Slipp physically and verbally assaults Blaggut, as he had done repeatedly throughout the book, but this time Blaggut gets up and strangles Slipp with an impressive "fuck you" speech:
""Fool! Aye, I was a fool, an oaf, an idiot, an' all those things you said I was. That's because I took up with you, cap'n, you're bad all through, you'll never change, that's why I gotta do this. Sorry, Cap'n!"
Redwall example #5 (get the idea that Brian Jacques likes this trope?): Ublaz's pet coral snake which he controls through hypnosis bites him when he treads on it while swordfighting Martin the Second.
Redwall Example # 6: Gabool the Wild is killed by the scorpion he captured a long while ago and constantly taunted.
In Jack Chalker's Four Lords of the Diamond series, the antagonist had captured one of the four mental clones (mind-wiped criminals with the agent's personality and memory imprinted on them) of the agent sent to stop him and had changed him into a female sex-slave. He brings her to a face to face meeting with the agent in order to gloat...only for the agent to utter a trigger phrase that causes her to assassinate the villain.
In Flash for Freedom! the evil slaver captain John Charity Spring is shot in the back by a half-addled crew member he'd previously viciously whipped. Admittedly, the captain had good reasons to be angry with the fool, but still...
In Graham McNeill's Warhammer 40,000 novel Storm of Iron, a daemon decides to possess Larana Utorian, instead of the Berserker holding her captive. It lures her in with promises of Revenge — which she does get.
Lu Bu does not learn from his own experience. Mistreating his generals causes many of them to defect during the siege of Xia Pi. One steals his famous horse Red Hare, while two others steal his weapon and bind him while he's sleeping.
Thomas Theisman: "I think we've had quite enough of those kinds of trials. Goodbye, Citizen Chairman."
In Vivian Vande Velde's The Changeling Prince, the Big Bad releases The Dragon from his restraint...at which time the audience discovers that he was a literal dragon and not happy about his forced servitude.
At the end of Harry Potter, seemingly loyal Death Eater Narcissa Malfoy seizes the opportunity to help Harry fake his own death, thereby almost single-handedly ruining Lord Voldemort's final attempt to return to power. This is a bit of Laser-Guided Karma, as Voldemort had alienated Narcissa by treating her son Draco as more or less cannon fodder.
The end of that series pretty much served as a "bit 'em if you want 'em" moment for put upon characters, especially in the huge battle at the end. A notable example is when the House Elves join in, led by Kreacher. It has been established that Death Eaters basically consider House Elves to be silly inferior servants and make them do all sorts of horrible things. It was also revealed earlier that Voldemort used Kreacher to test a terrible potion to hide the horcrux locket. Another House-Elf example would be Dobby, who goes back to the Malfoy Manor (where it was established that he lived in fear and pain as a servant) to save Harry and his friends. While there, he drops a chandelier on Bellatrix and disarms Narcissa before angrily telling them that he's not under the Malfoy family's control and will save Harry if he pleases.
A darker example would be Kreacher who after constant abuse by Sirius Black, eventually starts working for someone else and finally deceives Harry into going to the Department of Mysteries room. Indirectly Kreacher got Sirius killed at the hands of Bellatrix.
God bless Emilia of Othello fame, exposing her husband Iago for the scum he is. True, it doesn't turn out well for her, but considering she knew how he would react, she's as close as Shakespeare came to writing a female Bad Ass.
She even has a smaller one before that, when she tells Iago off for thinking that she'd cheat on him with Othello. Keep in mind that Iago is a paranoid bugger who spends most of the play suspecting everyone of sleeping with his wife. Emilia is the only person who actually realizes and confronts him on this.
Lady Aquitaine manages a two-for-one in Captain's Fury: in disguise and unrecognized, she's first taken hostage by her former ally she'd discarded as useless as he tries to flee from Tavi's forces, and then is killed by her (former) spy Fidelis as collateral damage when he assassinates said ally.
Unfortunately averted, actually - Lady Aquitaine was dying, not dead. She was found by the Big Bad, who saved her life in exchange for her services as The Dragon.
Less ambiguous example in Furies of Calderon-Isana, in a final and desperately one-sided showdown with Kord (who has basically spent the entire book being an utter bastard to everything with a pulse), actually manages to cripple him. Kord demands that she finish the job, but she opts not to; she'd rather he be forced to face justice with an outside that reflects his personality. Or to put it another way, helpless and covered in feces. She enjoys telling him so perhaps a little too much.
Also used with Kord's ultimate fate. After Isana leaves him there, his other victim, an axe-crazy water witch he had drugged and repeatedly raped shows up. She proceeds to hang the scalps of Marat warriors on him, before telling him that Marat are searching the building for their foes, and that they will do unpleasant things because he has scalps of their people. She leaves, and the Marat show up shortly afterwards.
Katsa from Graceling has the Grace (enhanced ability) of death, and is used by her uncle, King Randa, as an enforcer- he sends her to kill criminals and torture those who defy his orders. Katsa founded the Council, an organization who help civilians who are persecuted by others, and grows a sense of morality through her actions as the founder... meaning that when Randa sends her to force a disobedient lord to send him one of his daughters (another lord asked Randa for help in finding a wife, and Randa asked the first lord, who had two daughters each with a large dowry (the understanding was that Randa would get the dowry and the second lord would get the bride) to choose a daughter to send him, the lord refused) Katsa realises that this is probably one of the worst things that Randa has ever asked her to do (in fact, she says that had someone else been sent to torture the lord into giving up one of his daughters, the Council would have sent someone to stop them), so she refuses to do so and when Randa attempts to have her thrown in his dungeon, she gives him a Shut Up, Hannibal! speech and leaves the country.
Subverted in The Adventurers where death knight Gorath killed his supervisor and ally after that guy abused the authority over him. Subverted because, being Lawful Evil, Gorath had warned him twice before the actual attack.
Seen in A Song of Ice and Fire when Sandor Clegane finally gets sick of working for the Lannisters, who've treated him with no lack of disdain and disrespect, and deserts. This particular instance is also humorously in keeping with the Trope name, given that Sandor is better known as "the Hound" / "Joffrey's dog" and even cites his reason for leaving as, "Even a dog gets tired of being kicked." Might edge into Bodyguard Betrayal but that he doesn't take any action against Joffrey specifically and instead starts opposing the Lannisters in general.
Possibly also seen with Lancel Lannister, who King Robert treats as a general dogsbody, humiliating and insulting him wherever possible. This doesn't end well for Robert.
In Fevre Dream, an early novel by the author of the above, Vampire Vannabe Sour Billy Tipton spends the whole book playing The Dragon and The Renfield to Damon Julian, convinced that he's to be rewarded with immortality. Mortally wounded at the end, he begs Julian to save him by completing the change, and Julian just laughs at him and admits that the whole deal was a lie. Billy's rebuttal is a knife through Julian's eye.
While he isn't exactly a villain, the second version happens to Albert in Mort. He is far too powerful a wizard for the faculty of Unseen University to defy him - but when Death has him by the throat and he orders them to throw him his staff, they are all struck with a mysterious case of deafness...
Twoflower to Lord Hong in Interesting Times. It would have ended quite badly for him too, if it weren't for the UU faculty.
The very first Conan the Barbarian story, "The Phoenix on the Sword," has Ascalante, a scheming rogue who wants to get his hands on Conan's throne in Aquilonia. His chiefest slave and chew-toy is Thoth-Amon, once a powerful sorcerer of Stygia, who was robbed of the ring that he used to work his sorcery by a Shemite thief, and who Ascalante has blackmailed into doing his will by means of leaving a sealed note with someone with instructions to inform his enemies in Stygia of Thoth-Amon's whereabouts if Ascalante should die by Thoth-Amon's hand. But then Thoth-Amon reclaims his ring from Dion, one of the nobles involved in Ascalante's conspiracy to kill Conan, and proceeds to take terrible vengeance upon Ascalante by summoning a demon of Set to kill him and everyone with him, royally fucking up Ascalante's plans in the process.
Hanno is avenged in Buddenbrooks by Kai biting Hagenström Jr.
Maurice from Malevil is an unwilling recruit in Vilmain's bandit army. He defects to Malevil the night before the battle and he's the one who kills Vilmain in the end.
In Tithe, after Kaye poisons Nephamael with iron nails from her boots, Corny, who he'd been keeping like a pet for the past few chapters, grabbed a nearby knife and stabbed him over and over again.
This trope is pretty much the entire plot of Stephen King's Carrie. That is one dog that bites back hard.
The Extinctionists, a group of minor villains in Artemis Fowl: The Time Paradox, enjoy capturing endangered animals and subjecting them to executions. In fact the Big Bad of the book stages the executions and keeps the animals sedated in a laboratory beneath the Extinctionist's compound. When Artemis sabotages their annual conference, the animals break out of the lab, and many Extinctionists are mauled and trampled in the ensuing stampede.
In Kraken, Paul, the unwilling host of the magical mob boss known as the Tattoo (who is a literal talking tattoo inked onto Paul's back), finally tires of being forced to participate in crimes and murders and repeatedly being threatened, and stabs the Tattoo's chief enforcer to death, escapes his men, and has Tattoo's mouth sewn up.
Elizabeth Bathory in Count and Countess to both her husband and her majordomo. Her husband, impotent, has the majordomo impregnate her against her will in order to produce an heir. After snapping, she kills the both of them in gruesome but satisfying ways.
Two related examples in the Sister Mary Helen novel Death of an Angel. First, Angelica Bowers means to murder her domineering, often abusive mother. Her plan is to go on vacation for a week or two after smothering Mama, and in the days leading up to this she makes sure the dogs get just enough food to survive but not enough that they won't still be hungry. Then, when Mama is dead, she will set them loose on the corpse. It doesn't work out that way; she is injured in the fracas with Mama, the criminal the A plot is concerned with pays a very hostile call, and then Sisters Mary Helen and Eileen show up (saving her from him in the process) followed by the police—about that time the dogs emerge from the basement and smell the blood from Angelica's face wound. They also have to know that she's the one been keeping them hungry all this time. She dies of the resulting injuries the next morning.
In one of the Animorphs books, The Council of Thirteen sends a warrior known as The Inspector to evaluate Visser Three's progress in trying to Take Over the World. The Inspector spends the whole book mocking and belittling the Visser. Eventually, Marco turns into a cobra and bites him. The dying Inspector begs for help, only for Visser Three to mock him and leave.
In the final arc of AnimorphsVisser One finds himself betrayed by his security chief Tom. Guess he should've promoted him when he had the chance.
Septimus Heap - Magyk: The constant mistreatments in the Young Army prompted Boy 412 into a Heel-Face Turn and helping the Heaps escape from the Hunter and the Custodian Guards.
Swedish writer Simona Ahrnstedt gives us a downplayed example of this in Överenskommelser. The female protagonist Beatrice has been abused by her tyrannical uncle for five long years, to the point where she was forced into a marriage with a man, who was forty years older than her and treated women like dirt. But she gets a moment of awesome towards the end of the story, where she gets a small revenge on her uncle. Not only does Beatrice claim the right to "his" house, which he basically had stolen from her, despite that she had inherited it from her grandmother. (What makes it even more awesome is that she sells the house to use the money for education for girls.) This leaves her uncle homeless, but do we really feel sorry for him? Beatrice also reminds him of that his daughter wants nothing more to do with him, and that even his wife has left him...