Bayern started to control the game and both Mandzukic and Thomas Muller came close, but their respective efforts went wide.
Hoffenheim won a rare corner and took full advantage as Sule stabbed in from close range, Bayern conceding first for the third league game running.
However, they were back level inside five minutes as Franck Ribery found Mandzukic, who finished low from inside the box.
The first chance of the second period fell to Kevin Volland, but his effort from just outside the box went high over the goal.
Ribery then turned provider for what proved to be the winner, passing to Thomas Muller who struck low from the edge of the box.