Speaking of the Horrible Doctor, in another episode Barney tries to teach Lily how to do an evil laugh.
Another episode had Barney (Neil Patrick Harris) using actors to play the roles of his family. About his [faked] son, he comments that "Child actors were better 20 years ago," which is exactly what (and when) Harris used to be.
Another one is with Alyson Hannigan's character. When having cold feet before her marriage, one of the items on the list of experiences to have is a big lesbian experience. Her most famous role is lesbian witch Willow from Buffy the Vampire Slayer
Lily's Ambiguous Bisexuality and her implied lesbian crush on Robin are also a possible reference to Willow.
Lily's demon eyes and voice (Slapsgiving, The Stinson Missile Crisis, The Lobster Crawl, The Lockett) is suspiciously similar to "Dark Willow" from season six of Buffy.
Also Lily's favorite name for her baby: Tara, the name of Willow's girlfriend in Buffy. At the wedding she wants the Kennedy package, which just so happens to be Willow's other girlfriend.
Season 5, "The Playbook": Barney creates a website that features a picture of him, in scrubs, with a stethoscope around his neck. Hmmm, where have we seen that before?
In "Blitzgiving", Jorge Garcia played a cameo role. At one point someone asks for random numbers and he immediately shouts "4,8,15,16,23,42!" the Arc Numbers from Lost. His character is also cursed with being unlucky (as was his Lost character), and compares said curse with being on an island for eternity.
Season 8 episode "P.S. I Love You" featured a cameo from Dave Coulier, Bob Saget's (the narrator) Full House co-star. Coulier does his signature "cut-it-out" routine followed by Saget saying "I always liked that joke."
The season seven episode "No pressure" has Barney compare Lily and Marshall to preppy kids who stage and bet on hobo fights. NPH was a preppy kid who staged and bet on hobo fights on Boomtown.
Season 3, "Wait for It": When Ted is making out with Mandy Moore's character at the bar, her song "Nothing That You Are" is playing in the background.
Barney aka Neil Patrick Harris pretends to be Neil Armstrong and spend about a minute one of his women spends going "Neil, Neil, Neil, Neil...Armstrong"
In the same episode, when asked about the song that Robin had done, "PS I love you", Coulier said "Why do they always think it's about me?". Coulier was (allegedly) the subject of Alanis Morissette's song You Oughta Know, and Alanis was the inspiration for Robin Daggers
In a season 6 episode, Robbie Amell plays a character who goes by "Scooby" and acts like a dog. He was in two Sccoby Doo movies.
During their conversation in "Garbage Island" when Ted thinks The Captain (played by Kyle MacLachlan) suspects him of breaking up The Captain and Zoey's marriage, Ted spits out his brandy in shock and tries to cover it by saying "That's some damn good brandy." This is likely a nod to MacLachlan's role as Special Agent Dale Cooper on Twin Peaks, who repeatedly exclaims some variation on "That's some damn good coffee!"; the first time he does so is after a Spit Take.
Another possible coincidence for "The Mother" (Cristin Milioti), who earned a Tony nomination as "Girl":
Entertainment Weekly: What is it with you and nameless characters? Cristin: You know what? You are the first person to bring that to my attention, and you've blown my mind. Maybe I don't have a memorable face. [Ed. note: not true.]