Now, first of all, the record for most years in Congress after being on a national ticket must be Strom Thurmond, who served in the Senate from 1955 through 2003 (that is, his last term expired in January 2003). No one is going to beat that soon, but of course that's not a major party nomination.
Who served longest in Congress after a major-party national nomination? I'm guessing that it might be Bob Dole, nominated in 1976 and remaining in the Senate until 1996. Is there anyone longer?
John Quincy Adams only served from 1831 until his death in 1848, so fewer years -- but he was in Congress 24 years after he was elected president in 1824, so he was in Congress longer after his first run than was Dole.
Dole was on national tickets twenty years apart, in 1976 and 1996. So was Richard Nixon, in 1952 and 1972; of course, Nixon did it five times, total, while Dole's twenty year gap is (probably?) the record for that one. But twenty years total spread isn't the record for that; you need the other guy who was on a national major party ticket five times, Franklin Delano Roosevelt, who ran it to 24 years (1920-1944). FDR also held federal office 25 years after his first time on a national ticket, edging out JQA.
Ah, but that's not the record. Henry Clay ran for president in 1824, and he died as a Senator in 1852, four years after Adams and a grand total of 28 years after his first national run. However, he had fewer than 20 post-run years in Congress, so he doesn't match Dole on that.
While I'm at it...John Calhoun was elected VP in 1824, and he too died a Senator, in 1850. No records for him, unless I cut it more finely.
OK, who am I missing? I glanced through lists of major party tickets and didn't notice anyone who seemed a likely candidate to me, but I'm hardly an expert on 19th century VP candidates...
(Updated, to correct a really awful math error. Yikes!)