Niko Kovac's side, which was again missing the injured Manuel Neuer, had hit back following Maximilian Mittelstadt's third-minute opener, with Serge Gnabry scoring a brace.
However, substitute Davie Selke seized upon Hummels' dreadful header back towards Neuer's deputy Sven Ulreich to force extra time.
And it was Coman, with his first goal since December, who won it by heading in from close range.
Bayern felt injustice inside the opening three minutes when Leon Goretzka was booked for diving having gone down in the box, despite Karim Rekik appearing to make contact with him.
The visitor was even more peeved when Mittelstadt fired past Ulreich after the Bayern defence failed to deal with a long ball.
It was behind for just four minutes, Gnabry beating Rune Jarstein at his near post to equalise with a first-time drive after Joshua Kimmich's near-post cross had been cleared to him.
Gnabry's second goal arrived shortly after half-time. Niklas Sule and Robert Lewandowski were involved in the move, which led to James Rodriguez's pass around the corner to Gnabry, who confidently found the bottom-left corner of Jarstein's net.
Bayern was coasting to the next round until Hummels' lapse in concentration handed Hertha a 67th-minute equaliser with just its second shot on goal.
It came from a Bayern error as Hummels failed to realise Selke was lurking behind him, and the substitute easily collected the ball and rolled it under Ulreich to make it 2-2.
Bayern still had a great chance to prevent the game from heading to extra time, but James got his body shape all wrong when attempting to steer home David Alaba's cross and diverted the ball wide with his thigh.
Kovac's side then struck eight minutes into the additional period to restore its lead via a scrappy goal that Hertha should have prevented.
Goretzka's nod down from Kimmich's cross was latched onto by Lewandowski and he hooked the ball over Jarstein and into the air, with Coman beating three defenders on the line to head in.