Happens in all seven Harry Potter books to all three main characters. Justified to an extent — their robes makes it rather easy to stomp someone's foot without it being noticed, so it's the main way they get each other to shut up. Three examples for each character:
In the sixth book, Harry kicks a wall out of frustration and hops;
in book three, Ron steps on Hermione's foot;
and in book seven, Ron accidentally nudges a piece of white-hot cursed metal with his foot (long story).
In Order of the Phoenix, when Ron starts to make a blunder while they're out in public, Harry actually mentally laments that they're in Muggle clothes and thus it would be too noticeable to stomp on his foot.
In The Casual Vacancy, the book Rowling wrote following the Potter series, this happens deservedly to Simon Price after he aims a kick at his son and misses.
Discworld: One of AdoraBelle Dearheart's favorite tactics against people who makes sexist remarks, or try to stop her from smoking her ever-present cigarettes. It helps that she wears stiletto heels. Though she suffers the effects of this trope herself as well when she decides to spike the foot of a City Watch officer who's made of rock.
Michael tries to break a thick wooden rod he's been chained to in the Knight and Rogue Series by kicking it over and over. While this works in the long run, during one particular moment of panic he slams his foot into it so hard that he thinks he's broken his own bones for a minute.
In Mr. Grumpy, the eponymous character stamps on Mr Happy's foot after the latter tells him that he needs to change his ways
In Prince Caspian, the Narnian mice weaponize this toward the Calormene soldiers. Justified because they cannot reach higher than the belt.
In the Transformers: Shattered Glass story "Blitzwing Bop", a shopkeeper gets annoyed at Soundwave for accidentally chasing off his star attraction, and kicks him in the ankle in anger. Seeing as how, well, Soundwave is a giant solid metal robot and all, it hurts the shopkeeper's foot a lot more than it hurts Soundwave. (Though Soundwave does consider it "Most bogus!")
Septimus Heap: It is mentioned that Spit Fyre likes to do that with people, so that Jenna cautions Wolf Boy against getting too near when they're fetching the dragon.
In the Junie B. Jones book Junie B., First Grader: One Man Band, Junie B. accidentally breaks her toe when she kicks her mother's watering can that has a picture of a cow. Her sore toe became important afterwards.
In one of his stories, humorist Patrick McManus discusses this trope, commenting on the somewhat magical propensity of already-injured toes to attract further damage.
In The Girl Who Kicked The Hornet's Nest, tiny-but-fierce protagonist Lisbeth finds herself fighting a giant with congenital analgesia. To even the odds, she hides under some furniture with a nail gun and literally nails the giant's feet to the floor. He can't feel the nails, but he can't move, either.
In Amber Brown Is Tickled Pink, Amber, her mother and her stepfather to be visit Camp Sukkatukket, a camp owned by the father of one of Amber's classmates, Fredrich Allen. When Fredrich spots them, he drops a hammer that he was using to repair the cabin porch out of shock and then starts hopping up and down. He dropped it because he wasn't expecting Amber and her family there and the two of them aren't even friends at the time. (Though they become friends during the visit.)
Even less comedic in Mercedes Lackey's ''Arrow's Fall. After being caught trying to escape Hardorn, Kris is killed and Talia is captured and tortured. Among the tortures is severe bone-crushing torture to her feet. Healing her broken feet after she is surprisingly rescued is also incredibly painful, because she has to help and can't use pain killers or anesthesia. Nothing Amusing about these injuries.