smart aleck (n.)
1865, of unknown origin, perhaps in reference to Aleck Hoag, notorious pimp, thief, and confidence man in New York City in early 1840s [Barnhart]. See smart (adj.). Related: Smart-alecky.