"I've decided to play #opengstaad," the world number three tweeted on Tuesday.
"Very excited to play in Switzerland this summer," he said.
"This was the event that gave me my first wild card in '98!"
Federer crashed out of Wimbledon, where he was the seven-time champion, at the hands of Ukraine's 116-ranked Sergiy Stakhovsky in his worst Grand Slam defeat for a decade last week.
The second round loss ended his run of 36 consecutive Grand Slam quarter-final appearances, having not gone out of a major before the last eight since the 2004 French Open.
It was his earliest Wimbledon defeat since he was knocked out in the first round in 2002 by Mario Ancic.
The following year he lost in the first round of the French Open to Luis Horna.
Federer won the Gstaad title in 2004, the last time he entered the tournament.
The Gstaad event gets underway on July 22nd.