Ferguson and his co-star Eric Stonestreet, who play married couple Mitchell Pritchett and Cam Tucker on the show, appeared with Beckham and former Friends star Courteney Cox in a hot tub during a scene in Modern Family's Jan. 8 episode.
"The hot tub scene was really intense," Ferguson said. "Because not only was I in a hot tub, I was in a hot tub with Eric Stonestreet, David Beckham and Courteney Cox."
Ferguson said he ran into Beckham and his wife, fashion designer and former Spice Girls singer Victoria Beckham, who asked to be on the show.
"I ran into him and his wife, Victoria Beckham, outside a Soul Cycle class," Ferguson said. "They were like, 'We're huge fans of the show.' I was like, 'Well, if you ever want to come visit the set...' She's like, 'Take my number.'"
"So I was texting with Victoria Beckham later that day, she's like, 'We would like to come tomorrow,'" he added. "So I hosted them on the set and everyone's like, 'The Beckhams are here. Have you heard the Beckhams are here?' I'm like, 'Yeah, they're my guests.'"
Cox had shared photos with Ferguson, Stonestreet and Beckham from the Modern Family set in October.
"Too hot in the hot tub! #modernfamily," she captioned the post.
"It's very emotional," Ferguson said on Ellen. "I adore all of them so much. It's really, really sad."
The Modern Family cast attended an emotional final table read earlier this month. Bowen, who plays Claire Dunphy, said on Ellen in January that she plans to avoid the cast's "crying fest" following the finale.