The Greeks scored on the break when Kostas Tsimikas's cross found Youssef El Arabi at the far post and the Moroccan beat keeper Manuel Neuer.
Bayern, struggling for form since their 7-2 win at Tottenham Hotspur earlier this month, recovered to level with Lewandowski in the 34th minute.
He then put them ahead, stabbing in from close range against the run of play in the 62nd for his 18th goal in 12 games in all competitions.
Corentin Tolisso added a third with a curled shot in the 75th before the Greeks cut the deficit with Guilherme's deflected effort four minutes later.
The win lifted Bayern to nine point from three games. Tottenham crushed Red Star Belgrade 5-0 to move up to second place on four, one ahead of the Serbs. Olympiakos are bottom with one point. (Reporting by Karolos Grohmann, editing by Pritha Sarkar)