Gomez, making a rare start in place of the team's top scorer Mario Mandzukic, scored the only goal of a lacklustre game when he flicked in a Franck Ribery header in the 38th minute as Bayern grabbed their 11th away win this season and their seventh straight victory this year.
The Bavarians, who made five changes to the team that ousted holders Borussia Dortmund from the German Cup on Wednesday, lacked pace in attack but were rarely threatened by lowly Hoffenheim.
Bayern's 20th win in 24 league games lifted them to 63 points, with champions Dortmund second on 46.
"It was a laborious victory. It was not sparkling and it was not brilliant but even for this you get three points," Bayern coach Jupp Heynckes told reporters. "It was tough because our opponents have their backs to the wall.
"We were not lively enough at the start and it took some time until the motor was warmed up," added Heynckes, whose team face Arsenal in the return leg of their Champions League round of 16 this month.
Bayern were without winger Arjen Robben, who was again ruled out with a muscle injury, and Hoffenheim briefly threatened in the opening stages with two long-range efforts from Daniel Williams.
The visitors gradually found their rhythm and Gomez rounded off a lightning quick move that started with Hoffenheim losing possession in midfield to give Bayern the lead.
Bayern were playing well below par, but had chances to extend their lead in the second half.
Bastian Schweinsteiger twice rattled the woodwork with free-kicks and David Alaba drew a spectacular late save from Hoffenheim keeper Heurelho Gomes.
Hoffenheim, 17th on 16 points and five points below the relegation play-off spot, defended bravely throughout but were toothless up front.
In the only other game on Sunday, Mainz 05 missed the chance to move back into European contention with a 1-1 draw at Fortuna Dusseldorf to stay eighth on 34 points.
Dortmund remained second after easing past Hannover 96 3-1 on Saturday with two goals from Robert Lewandowski, who is reportedly close to signing a deal with Bayern.
Bayer Leverkusen are a point behind in third after coming from a goal down to score twice in the last eight minutes and beat VfB Stuttgart 2-1 on Saturday.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.