O’Hara studied law in North Carolina and at Howard University and served as a clerk for the 1868 North Carolina state convention that drafted a new state constitution.
In 1871, he completed his law apprenticeship and passed the North Carolina bar exam. From 1872 to 1876, O’Hara served as chairman of the board of commissioners for Halifax, North Carolina and from 1883 to 1887 he served as a Republican member in the United States House of Representatives. He was the second African American elected to Congress since the Civil War from North Carolina. During his time in Congress, O’Hara introduced one of the first bills to make lynching a federal crime. He also introduced a bill to prohibit gender based salary discrimination in education. After being defeated for reelection, he resumed his private law practice and died September 15, 1905.