Treble-hungry Bayern crush Wolfsburg in cup
Germany international Gomez, who came on as a substitute in the 77th minute struck three times in six minutes to complete another big-scoring win this season.
The Bavarians, who won the Bundesliga title earlier this month and face Barcelona in their Champions League semi-final first leg next week, will face either VfB Stuttgart or Freiburg, who play on Wednesday.
With Franck Ribery suspended, defender David Alaba injured and coach Jupp Heynckes rotating the line-up, Bayern needed some time to adjust.
"Wolfsburg made it hard for us for a long time," Heynckes told reporters. "We were not fully there at the start. I told them at halftime what I think must change and it seems to have worked.
"I am happy for Mario that he got his hat-trick. It goes to show that we have three top strikers in this team."
Forward Mario Mandzukic struck against his former club in the 17th minute after good early work from Shaqiri. Arjen Robben doubled their lead after another pin-point pass from the Swiss midfielder.
Wolfsburg briefly battled back and Brazilian Diego cut the deficit with a stinging 18-metre shot that flew past Manuel Neuer on the stroke of half-time.
Shaqiri, however, restored Bayern's two-goal cushion with an unstoppable low drive from the edge of the box five minutes after the restart and cut back for substitute Gomez to tap in after a darting 20-metre sprint in the 80th minute.
The Germany forward, who lost his spot to Mandzukic this season and could be playing his last matches for Bayern with reports linking him with a move to England and Spain, had time to grab two more as Wolfsburg imploded.
Bayern secured their 23rd German league title - their first since 2010 - earlier this month with six games to spare.