Amid pre-match fears of a double-figure scoreline, Cottbus proved their doubters wrong by holding Bayern off for half an hour before Lewandowski opened the scoring from close range.
Lewandowski and Kingsley Coman both hit the bar before half-time, but it wasn’t until the 65th minute that Coman doubled the lead with a fizzing long-range effort.
Lewandowski then deflected in Leon Goretzka’s shot six minutes from time to complete a comfortable win for Bayern, who have not lost in the first-round of the competition since 1994.
There was just time for club record signing Hernandez to come off the bench to make his competitive debut and for Berkan Taz to score a consolation penalty for the hosts.
“My team played well today. I would have liked to bring Hernandez on earlier than the 89th minute, but he has a long injury behind him,” coach Niko Kovac told Sky.
Kovac also all but confirmed the arrival of Croatia winger Ivan Perisic on loan from Inter Milan ahead of the game, telling ARD that he “assumed” the transfer would go ahead.
Perisic, 30, was in Munich for a medical check on Monday morning, but the club are yet to officially announce the transfer.
Kovac’s side begin their Bundesliga campaign at home to Hertha Berlin this Friday.
Elsewhere on Monday, Wolfsburg needed two goals in extra time to win an eight-goal thriller against third division side Halle.
The underdogs twice came from behind, scoring an injury-time equaliser to make it 3-3 before Robin Knoche and Josip Brekalo sealed a 5-3 victory for Wolfsburg in extra time.
Second division clubs Karlsruhe and Stuttgart also reached the second round with wins over Hanover and Hansa Rostock.