Although Borussia Dortmund later secured the Bundesliga title when they beat Borussia Moenchengladbach 2-0, the win guaranteed Bayern Champions League football next season.
Schalke, in the third direct Champions League place, have 57 and fourth-placed Gladbach 56 in the Champions League playoff spot.
At the other end of the table,
The result plunged second-bottom Hertha into further trouble while
Bayern had recently publicly renounced any pretensions of winning the Bundesliga, preferring to focus on reaching the final of the Champions League, which will be played in their own stadium.
They visit Real Madrid for the second leg of their semi-final on Wednesday, having won the first leg 2-1 last Tuesday.
They made eight changes to the side which beat Real and fell behind in the 51st minute when Claudio Pizarro headed on a corner and Naldo fired home from close range.
With Werder dominating, Bayern brought on top scorer Mario Gomez and Ribery. The Frenchman had only been on for a few minutes when he broke down the left and sent over a low cross that Naldo, under no pressure, side-footed into his net from 12 metres.
Then Ribery wriggled past his marker and placed a low shot into the far corner.
Kaiserslautern stunned Hertha when Oliver Kirch and Andrew Wooten scored in a 12-minute spell before halftime.
Peter Niemeyer replied on the hour for Hertha, although he was later sent off for a second bookable offence. Hertha, promoted last season, are two points adrift of Cologne.