The 32-year-old actress, who has daughter Suri, five, with husband Tom Cruise, has agreed to play a promiscuous Jack-O-Lantern in a Halloween special of the show, New York Magazine's Vulture blog reported.
The history of the character spans back to the show's freshman season when Ted mentions a love interest that he once met at a Halloween party.
Creator Craig Thomas said he couldn't be happier with their choice of star.
'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,' he said.