Michael J. Fox was 23 years old when Back to the Future was released in 1985, playing 17‑year‑old Marty McFly.

He was born on June 9, 1961, and the movie came out in July 1985, which puts him at 24 by release but about 23 during most of the filming.

TL;DR: He was in his early 20s (about 23) playing a teenager in Back to the Future.

Information gathered from public forums or data available on the internet and portrayed here.