O'Leary served as Lord Mayor of Cork from 1972–73. He was an unsuccessful Fine Gael candidate for Dáil Éireann at the 1965, 1969, 1973 and 1977 general elections for various Cork constituencies. In 1981, he was nominated by the Taoiseach, Garret FitzGerald as a member of the 15th Seanad. He was a political activist one of the group known as the 'National Handlers'. Prior to qualifying as a barrister he was an accountant. He was nominated again in 1983, and served in the 17th Seanad from 1983–1987. He did not seek re-election in 1987.
He was later appointed a Circuit Court Judge and later again promoted to the High Court. He chaired enquiries into the proposed Luas light rail system for Dublin in 1997 and 1999 which were praised for their promptness. While a High Court judge he served as Chairman of the Residential Institutions Redress Board. He died in Cork on 22 December 2006.