Bayern Munich needed a second half penalty from Robert Lewandowski to avoid defeat at home to Hertha Berlin on the opening night of the Bundesliga season.