Third-placed Hoffenheim, whose 29-year-old coach Julian Nagelsmann is the youngest in the league, dominated the first half and deservedly won with a goal from Andrej Kramaric.
Bayern, who have 65 points from 27 games, are still 13 clear of second-placed RB Leipzig, who visit Mainz 05 on Wednesday.
Hoffenheim, who had never previously beaten Bayern in the league, are third with 51 and still on course for a Champions League place while Borussia Dortmund remain their closest rivals, remaining fourth after easing past Hamburg SV 3-0.
Bayern were outclassed in the first half and fell behind to a Kramaic half-volley which goalkeeper Sven Ulreich could only deflect into his net.
Read the full article on eurosport.co.uk: Hoffenheim hand Bayern second league defeat of the season