Jupp Heynckes' side continued their march towards the Bundesliga title despite not being at their brilliant best against their relegation-threatened hosts
The Bundesliga leaders were far from their best, but in a rare start, Gomez produced a close-range finish to seal the victory.
The win means the Bavarians remain 17 points ahead of Borussia Dortmund at the top of table while Hoffenheim stay embroiled in a relegation battle.
The league leaders looked to stamp their authority on the game early on, and Bastian Schweinsteiger tested Heurelho Gomes with a low free kick that the former Tottenham goalkeeper could only turn round the post.
Despite their lowly league position, Hoffenheim were not going to let the visitors have everything their own way, and Danny Williams should have done better when a cross from the left evaded three Bayern defenders before finding him at the back post.
The midfielder could only find the side netting with that effort, but that did not deter him and he tried his luck minutes later, though he again missed the target with a powerful shot from distance.
Both sides were failing to make any real periods of possession count until Franck Ribery headed Jerome Boateng's diagonal ball into Gomez's path, and the Germany international made no mistake as he squeezed the ball into the bottom corner despite pressure from Gomes.
Breaking the deadlock certainly galvanised Jupp Heynckes' side, and they almost doubled their lead before the break when skipper Philipp Lahm broke into the box and saw his effort parried away by Gomes.
Williams was proving the biggest threat for the hosts, and he almost grabbed an equaliser on the verge of half-time as he forced Tom Starke into a save low to his right after breaking from midfield.
The start of the second half offered little in the way of goalmouth action, and it was not until the 67th minute that either side had a meaningful effort on goal, as Stephan Schrock forced Starke into an acrobatic save from the edge of the area.
Marco Kurz's team were beginning to show much more attacking intent, though they nearly fell further behind as Schweinsteiger's free kick beat Gomes only to crash against the crossbar.
Schweinsteiger was a constant danger from dead ball situations, and he again rattled the woodwork from a free kick as the match entered its final 15 minutes.
Mario Mandzukic replaced Gomez up front, and he went close to sealing the points as his placed header drifted narrowly wide of the right-hand post.
In searching for an equaliser, Hoffenheim began to leave gaps in defence, and Ribery and David Alaba both almost took advantage, but Gomes was equal to both of their efforts from the edge of the area.
The hosts huffed and puffed as they looked to claim an unlikely point, but Heynckes' side were ultimately comfortable in closing out the win.