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.
Niko 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.