John Quincy Adams did. After losing in the presidential election in 1828 to Andrew Jackson he ran and was elected to the House of Representatives for Massachusetts' 12th district. He served until his death in 1848. I hope this is helpful.
I came across this while reading about the nullification crisis in Donald J. Ratcliffe, ‘The nullification crisis, southern discontents, and the American political process’, American Nineteenth Century History, 1, no. 2 (2000), 1-30, p.12
Grover Cleveland failed of re-election after his first term, and four years later ran again for President and was elected to a second term. Theodore Roosevelt opted not to run for re-election in 1908, but ran for President again in 1912, but did not win. Gerald Ford and Ronald Reagan seriously discussed the former's being the latter's Vice Presidential nominee in 1980, four years after Ford was defeated in an effort to be elected President in his own right, having become President two years before that upon Nixon's resignation.
William Howard Taft became Chief Justice of the United States after his Presidency (not an elective office, obviously).
Vice Presidents of the modern era more often have a political afterlife. Dan Quayle ran for President in 1996. Walter Mondale ran for US Senate in 2002. Hubert Humphrey ran for US Senate in 1970 (winning and being re-elected in 1976) and for President in 1972. Richard Nixon ran for Governor of California in 1962 and for President in 1968 (winning and being re-elected in 1972).
John Quincy Adams also ran for governor of Massachusetts in 1833, but was defeated.
John Tyler was elected to the Confederate House of Representatives in 1861, but he died before he could take office.
Andrew Johnson was elected to the Senate in 1874 after he lost an election for the Senate in 1868 and the House of Representatives in 1872.
Edit: Of course it was Andrew Johnson and not Andrew Jackson, thanks for the correction.