After Napoli beat Manchester City 2-1 to go second in the table, Bayern are now five points clear at the top and will win Group A regardless of their last game away to the Premier League leaders.
This was Bayern's fourth win in this season's European campaign with only last month's 1-1 draw at Napoli blotting their perfect record.
Munich's Allianz Arena will host the final next May and the Bavarian giants have made no secret of their desire to win the Champions League for the first time since 2001.
"We are proud and happy to have achieved our goal before the end of the group phase," said goal-scorer Mario Gomez. "Franck Ribéry was outstanding."
Having fallen to a fifth straight defeat, Villarreal are now sure of elimination and even their dreams of finishing third, to secure a Europa League berth, are also dashed.
Bayern bounced back from Saturday's 1-0 home defeat to German champions Borussia Dortmund in the Bundesliga with an impressive display as Ribéry found plenty of space to exploit.
Coach Jupp Heynckes started with Arjen Robben making his second appearance after a groin surgery to help cover for the injured Bastian Schweinsteiger, who broke his collarbone in the 3-2 win over Napoli a fortnight ago.
Ribery opened the scoring after just three minutes when Germany midfielder Toni Kroos set up the Frenchman to fire home from all of 12 metres out. Bayern then went 2-0 up when hot-shot striker Mario Gomez scooped the loose ball into the net after midfielder Anatoliy Tymoshchuk hit the post.
Dutch midfielder Jonathan de Guzman pulled a goal back for the Spanish on 50 minutes after a mistake by Kroos was pounced on by defender Joan Oriol, who sprinted down field for de Guzman to score.
Munich made sure of the win when Kroos played a well-timed diagonal pass through the Villarreal defence and with Lopez off his line, Ribéry fired into an empty net on 69 minutes for his eighth goal of the season.
Bayern are under no pressure now for their final group game in Manchester on December 7, while Villarreal will be playing just for pride the same night when they host Napoli.