The defeat puts a dent in Munster's play-off hopes and was just their second home league defeat of the season, marring O'Gara's all-time appearance record for the Irish region.
Cardiff were strengthened with the return of Jamie Roberts, returning from an elbow injury, and Leigh Halfpenny and took the lead through young fly-half Rhys Patchell via a penalty in the tenth minute.
Munster came into the game on a three-match winning streak after victories over Ulster, Connacht and Glasgow Warriors, but were forced into an early change with Duncan Williams replacing Conor Murray.
O'Gara, winning his 234th competitive cap, then replied to Patchell's earlier effort with a penalty of his own to make it 3-3 and that is how it stayed until half-time, with Sean Henry replacing Mike Sherry before the interval for Munster.
The second half got off to a much more frenetic start and wing Owen Williams managed to score the game's first try on 43 minutes which Patchell duly converted to give Cardiff a 10-3 lead.
Patchell passed to the returning centre Roberts who put in a well-timed inside ball to Williams who broke down the middle, past Felix Jones, and touched down under the posts to cap off a fine move.
O'Gara then cut the deficit to just four points with another penalty three minutes later but his Munster side lacked the cutting edge that had seen them prosper in recent weeks.
Then, capitalising on an error from replacement scrum-half Williams, who fumbled the ball out of the ruck, No.8 Copeland picked up the ball, evaded several weak Munster challenges and sidestepped O'Gara in the process to touch down with ten minutes remaining.
And when Patchell added the extras the Welsh region led 17-6 with a big ten minutes ahead of them - a period of play in which they produced some of their finest defensive work of the season during to hold on.
|Munster Rugby Score Card|
|Cardiff Blues Score Card|