Although the world champions wasted countless chances at the Parc des Princes, with Thomas Mueller notably hitting the woodwork twice, they were never threatened by the Irish, who finished third and still have a chance to qualify.
Germany came top with seven points, ahead on goal difference of Poland, who progressed with a 1-0 win over already-eliminated Ukraine. Northern Ireland have three points.
The result meant that Croatia, Slovakia and Hungary progressed without kicking a ball.
Joachim Loew’s Germany side will take on a third-placed team in Lille on Sunday while Northern Ireland will have to wait for the other groups’ results to see if they make the cut.
“We have had a lot of chances and the next step will be to take them and then this might be a good tournament,” said Gomez, who is now one short of Juergen Klinsmann’s Germany record of five goals at European Championship tournaments.
“If it is not meant to be for us to go through, we will be very disappointed,” said Northern Ireland keeper Michael McGovern, who had made a series of fine saves.
“It was busy today and mentally very hard. We knew every goal was crucial so wanted to keep it at one and maybe nick a goal of our own.”
Backed by their noisy and devoted fans, the Irish, in their maiden appearance at a European Championship, showed great resilience against a Germany team who appeared more inventive than in their first two group games.
Germany, helped by their opponents being forced to defend deep in their own half, played the sort of free-flowing football that, if matched by finishing, could be lethal in the knockout phase.
In the seventh minute, Thomas Mueller was played through by a clever Mesut Ozil knock on but shot straight at McGovern, who made several fine saves.
While Germany’s larger contingent of fans were outsung in the stands, their team were all over the Irish on the pitch.
In the space of two minutes, Ozil missed a decent chance, McGovern denied Mario Goetze from close range and Joshua Kimmich’s all too casual chip went over the bar.
In the 23rd, Gomez chested Kimmich’s cross into the path of Mueller, whose half-volley went just wide of the far post. Four minutes later, Mueller’s diving header hit the foot of the post.
“Will Grigg’s on fire,” the Northern Ireland fans sang, even though their celebrated number nine was left on the bench again.
On the half hour, Germany finally broke the deadlock when Mueller burst into the area, after being played through by Ozil, and played the ball back for Gomez, who coolly slotted the ball home albeit via a deflection off defender Gareth McAuley.
Mueller also missed a golden opportunity in the 36th minute when his effort rattled the crossbar.
Goetze then wasted two clear chances soon after the break before being replaced by Andre Schuerrle in the 55th minute.