Superb first-half goals from Javi Martinez and Toni Kroos and another from Frenchman Franck Ribery gave the hosts a 3-0 lead at the break.
Defender Dante headed in another on the hour and Gomez slipped past one defender to slot in seconds after coming on for his first league appearance this season after missing the first three months recovering from an ankle operation.
"We fully deserved to win and played a great game because we stuck with it from the start and we were aggressive," said coach Jupp Heynckes after his 200th league game on the Bayern bench.
"We had to stay focused especially in the back and the team was brave over 90 minutes."
The show of force lifted Bayern to 34 points from 13 games with champions Borussia Dortmund, their opponents in seven days time, leapfrogging into second place nine points behind with a 2-1 win at Mainz 05 - their third straight win in the league.
Schalke 04 dropped to third on 24 after drawing 1-1 with visiting Eintracht Frankfurt, who are fourth on goal difference. Frankfurt ended the game with 10 men after the sending off of Karim Matmour with a second booking.
Having drawn their last two games in the league and the Champions League Bayern were eager to show they are in complete control of their season ahead of the derby with Dortmund next week.
Spaniard Martinez's fine bicycle kick - his first goal for the Bavarians since joining in the close season for 40 million euros, gave the hosts a fourth-minute lead.
Kroos' spectacular 24th-minute volley from a Philipp Lahm pass made it 2-0 before Franck Ribery added another before the break.
Bayern were in no mood to let off and Dante headed in their fourth goal in a one-sided encounter.
Gomez was brought on in the 66th minute for Bundesliga top scorer Mario Mandzukic and showed he meant business a minute later, slotting in from the left.
"The goal was just amazing," said a beaming Gomez. "The feelings of happiness come pouring out and you feel how important football is to you. For me it was a huge highlight," said the Germany international who scored 26 seconds after coming on.
Werder Bremen and VfL Wolfsburg, who twice hit the woodwork, drew 1-1 with Klaus Allofs facing the team where he worked as sports director for 13 years before joining Wolfsburg last week.
Werder had Lukas Schmitz sent off with a second yellow card for a foul on Vierinha. The Portuguese then fed Dutchman Bas Dost for his sixth goal of the season that cancelled out Bremen's 35th-minute lead through Marco Arnautovic.
In a bad-tempered Bavarian derby, Nuremberg and Greuther Fuerth drew 0-0 but both had a player sent off. Nuremberg's Markus Feulner got a straight red card for a wild first-half tackle and Sercan Sararer was sent off with a second booking on the hour.
- Sports & Recreation
- Toni Kroos