The Blues launched a series of counter attacks from their own half, with replacement Jamie Roberts gaining good ground. However, Munster stood firm to take the points and end a run of five winless trips to Wales.
O'Gara's line-kicking and control at out-half was superb at times, with one particular kick off his weaker left foot pinning Cardiff right back at a crucial stage.
Captain Paul O'Connell, in only his first Magners League start of the season, was a pivotal presence for the table toppers, who also had strong contributions from the fit-again Felix Jones, Keith Earls and Denis Leamy.
Winger Leigh Halfpenny landed three penalties for the Blues who nipped ahead at 15-13 courtesy of Dan Parks' 54th-minute penalty. But O'Gara closed out the scoring to put a dent in the Welsh region's play-off hopes.
Andries Pretorius stood out in a Cardiff pack that lost props John Yapp and Sam Hobbs to yellow cards in the first half. The South African was busy throughout and won a number of turnovers, charging O'Gara down on one occasion and generally making a nuisance of himself.
An early ruck indiscretion allowed Halfpenny kick Cardiff ahead, before O'Gara missed his first shot at the posts three minutes later.
There was no clear pattern in the opening quarter but Munster were making the most of possession and it took a clever tackle from skipper Paul Tito on Mick O'Driscoll to win a penalty for the Blues, five metres from their own line.
Winger Earls pressed well on the counter and it was one such run which split the home defence wide open in the lead up to James Coughlan's try.
After Johne Murphy took a quick lineout throw, Earls drifted away from Sweeney and although he was hauled down in front of the posts, his offload invited Coughlan through and he powered over from close range.
O'Gara tapped over the simple conversion and although Halfpenny managed to reply for the hosts, referee Alan Lewis spotted Yapp throwing a punch at O'Driscoll just after the restart and the prop was promptly sin-binned.
O'Gara kicked two penalties while Cardiff were down to 14 men, yet the Blues were able to bounce back before half-time with two more kicks from Halfpenny.
Yapp's replacement Hobbs and Munster hooker Damien Varley were both yellow carded for throwing punches at each other as tempers flared in the 33rd minute.
Halfpenny kicked the resulting penalty for his side and added another in injury-time after Tony Buckley infringed at a ruck.
Both try-lines were rarely troubled in the opening 40 minutes, but Munster did have a sniff of a second when Jones raided through the middle and his attempted pass was dropped by the supporting Niall Ronan.
Blues director of rugby David Young unloaded his bench after the break, introducing the likes of Wales' Bradley Davies and Roberts and Scottish international Parks.
O'Gara was off target with a 48th minute penalty as he tried to improve Munster's 13-12 advantage. O'Connell and company were edging the exchanges up front, but Martyn Williams, Mike Paterson and Pretorius helped set up Parks' confidence-boosting drop goal.
The Cardiff crowd sensed a turning point, but back came Munster. Varley and O'Connell made the hard yards to win a close range penalty which O'Gara drilled over for a 16-15 scoreline.
Cardiff clung on as O'Gara failed to add to Munster's tally and following a half-break from Roberts on the left, Parks flicked a drop goal attempt to the right of the posts.
O'Gara found space out wide to keep Munster on the front foot and leave the Blues frustrated at their lack of territory in the final quarter.
Munster had enough in the tank to see out the win, with O'Gara, O'Connell and replacement Peter Stringer steering them home.
|Cardiff Blues Score Card|
|Munster Rugby Score Card|