Not the longest. After joining the Yankees and moving to the outfield, Babe Ruth went from 1921 (second year with NY) when he pitched two games, to 1930 when he started a game (and got a complete game win!). He would again start a single game in 1933, also a CG win.
So the Babe had around 9 years, give or take a few months, between pitching.
Although it wouldn't surprise me if a career minor leaguer may have done that at both ends of his career. Interesting trivia question.
EDIT:
Just found out the correct answer is Paul Schreiber, who went 22 years between ML pitching appearances! Source: https://www.baseball-reference.com/players/s/schrepa01.shtml