The world number four beat Alejandro Falla of Colombia 7-6 7-6 to win the grass court event for the seventh time in his career.
The 32-year-old told Sky Sports News: "I've left a little bit of my heart there. My big goal for the week was to collect the title, play good tennis and have fun. I've done that."
Federer has appeared in the final at the German tournament in nine of the last 12 years.