Munster led 10-3 at half time and O'Gara extended that lead with a penalty in the opening minute before an Alun Wyn Jones try and a penalty try put the home side into a one point lead (17-16) at the end of the third quarter.
O'Gara edged Munster in front with another penalty but it seemed that Ospreys would prevail when James Hook landed a long range effort with normal time just up.
In added time however, Munster worked their way downfield helped by a marvellous O'Gara touchfind and from the subsequent lineout, after two drop goal attempts, Munster forced the penalty for O'Gara to convert.
In a lively opening half, the best chance fell first to Munster when in the 15th minute Keith Earls made good ground up the left wing, chipped ahead, re-gathered but lost the ball forward when tackled as he crossed the line.
Minutes later, Conor Murray's last gasp tackle prevented James Hook scoring in the left corner.
Then in the 29th minute Lifeimi Mafi latched onto a clever O'Gara kick and he too lost the ball forward assisted by a nudge in the back, with the line at his mercy.
Dan Biggar opened Ospreys account with a 35th minute penalty, was wide with a second attempt at the start of the second half
Ospreys: L Byrne (A Bishop 33rd min); N Walker, T Bowe, J Hook, R Fussell; D Biggar, R Webb; R Bevington, R Hibbard, A Jones, I Gough, A Wyn Jones (capt), J Tipuric, M Holah, J Thomas.
Munster: F Jones; D Howlett, L Mafi, P Warwick (S Zebo 65th min), K Earls; R OGara (capt), C Murray (P Stringer 64th min); M Horan (du Preez 50th min), D Varley (M Sherry 64th min), J Hayes (T Buckley ht), I Nagle (T ODonnell 59th min), D OCallaghan, D Ryan, D Wallace, J Coughlan.
Referee: J Graces (France).