The home hope will be handed a wild card into the event - one at which he made his ATP debut back in 1998.
Federer's first-week exit from Wimbledon - he was surprisingly ousted by Sergiy Stakhovsky - left the world number three facing a longer than expected lay-off. His next tournament had been due to be the Rogers Cup in Montreal in early August.
However, he will now play the claycourt event in the Swiss Alps to get back in the swing of things.
The 31-year-old said he was "very excited" to be playing at a tournament he last visited in 2004 when he won the title.
He wrote on his official website: "I'm really looking forward to playing in front of my home fans in Gstaad this summer. I have got a lot of great memories of the tournament in the mountains of Switzerland."
Federer's compatriot Stanislas Wawrinka has also entered, while Janko Tipsarevic and Juan Monaco are other big names in the field.
Tournament director Jean-François Collet said: "We're already dreaming of a 100 per cent Swiss final between Federer and Wawrinka."
The tournament takes place from July 22-28.