The "Dawson's Creek" alum will play Naomi, "the girl in the slutty pumpkin costume that Ted looks for every year on Halloween," the network said in a synopsis. The character was first mentioned in Season 1 of "Mother."
Holmes is to appear in the Oct. 31 episode of the show.
"We're thrilled to have Katie Holmes joining us this Halloween to play a role literally six seasons in the making," Craig Thomas, series co-creator and executive producer of "How I Met Your Mother," said in a statement Thursday. "Katie is a lovely and talented actress, which is why we've saved for her perhaps the most classily-named character in our show's history: The Slutty Pumpkin."