The Bavarians looked lively in the early stages of the encounter, with David Alaba and Jerome Boateng seeing their efforts blocked in the opening 10 minutes.
After a spell of domination, Bayern took the lead in the 23rd minute, with Thomas Muller netting the first goal of the Bundesliga season with a header at the near post.
Kingsley Coman went close to doubling Bayern's lead 10 minutes later as he skipped past his marker before unleashing a strike that goalkeeper Oliver Baumann did well thwart.
That proved to be Coman's last action of the game as he was forced off due to an injury and replaced by Arjen Robben.
Hoffenheim came out a rejuvinated side in the second half and managed to grab an equaliser in the 57th minute with Adam Szalai profiting from Boateng's error to slot into the far corner.
The hosts were gifted a lifeline with 12 minutes remaining when Franck Ribery went down in the box and the referee pointed to the spot. Robert Lewandowski took the spot-kick but his effort was saved before Robben converted the rebound.
That's when the drama began as after consultation with the Video Assistant Referee (VAR), the referee ordered Bayern to take the penalty again, but this time Lewandowski did not miss as he gave Bayern the lead from 12-yards out.
VAR was called upon yet again in the 86th minute when Bayern thought they had grabbed a third through Leon Goretzka, but the midfielder's strike was ruled for a handball.
Four minutes later, Bayern got the third goal through Robben, who collected a pass from Muller before firing past Baumann from close range.