Halfpenny reduced the arrears with another penalty that was cancelled out by O'Gara's strike three minutes later, from a penalty award that saw John Yapp yellow carded.
Munster might have had a second try when Felix Jones carved open the Blues defence but just failed to find Niall Ronan with the line at his mercy.
A 28th minute O'Gara penalty extended Munster's lead but two late Halfpenny efforts left the game finely balanced at half time and both sides playinmg with 14 after Damien Varley and Sam Hobbs had been yellow carded by referee Alan Lewis.
In the second half the clearest chance came Munster's way when Earls again skinned the Blues defence only for the move to end when Murphy's chip-through was touched down.
A Dan Parks drop goal in the 52nd minute gave Cardiff the lead but O'Gara restored Munster slender advantage five minutes later and he should have extended that lead soon after but missed from 30 metres and to the right of the posts to set up a tense finish that Munster play the end game in the Cardiff hend of the stadium.
Cardiff Blues: C Czekj; R Mustoe, C Laulala, D Hewitt, L Halfpenny; C Sweeney, L Williams; J Yapp, R Williams, S Andrews, M Paterson, P Tito (capt), A Pretorius, M Williams, X Rush. Replacements: K Dacey, N Trevett, S Hobbs, B Davies, M Molitika, T Slater, D Parks.
Munster: F Jones; D Howlett, J Murphy, L Lifeimi, K Earls; R O'Gara, C Murray; W du Preez, D Varley, T Buckley, P O'Connell (capt), M O'Driscoll, J Coughlan, N Ronan, D Leamy. Replacements: M Sherry, M Horan, S Archer, D Ryan, P O'Mahony, P Stringer, S Tuitupou, D Cusack.
Referee: A Lewis (Ireland).