Episode 8 of How I Met Your Mother season 7. Guess starring Katie Holmes as the "Slutty Pumpkin"

Future Ted reminds his kids about how ten years earlier he met the Slutty Pumpkin, a girl in a provocative pumpkin costume who appeared to be very compatible with Ted, during the rooftop Halloween party. However, he lost the Kit Kat bar that she had written her number on and waited each year in vain for her to appear again.