The match appeared to be going away from PSG when Marco Verratti was sent off early in the second half and Kostas Manolas equalized for the visitors with nine minutes left.
However, Edinson Cavani sealed the win with an emphatic drive in the 90th minute to lift PSG on to 13 points.
While PSG were securing top spot in Group C, Benfica improved their chances in the same section with a late winner in a 3-2 victory at Anderlecht that took them up to seven, the same as Olympiakos.
The game swung both ways, with Chancel Mbemba giving Anderlecht an early lead before he put through his own net seven minutes into the second half to put Benfica 2-1 up.
Anderlecht made it 2-2 with time running out, which left Benfica facing the exit door until Rodrigo, who came on as an 87th minute substitute, hit the winner two minutes later.
Benfica can now qualify if their result in their last match at home to PSG is better than Olympiakos’ against Anderlecht.
Manchester City, who like Bayern had qualified before Wednesday’s games, beat Viktoria Plzen 4-2 thanks to two late goals from Alvaro Negredo and Edin Dzeko.
Plzen had twice levelled on a night that ended with City scoring four to complete a remarkable scoring sequence at home with three, four, five, six and seven goals in their last five matches at the Etihad Stadium — albeit not in order.