Commentaries:
Obviously, at age 8, he is not handling the day-to-day matters of the kingdom. He holds the title of king, but he is more than likely being schooled and groomed by a regent. Part of that schooling is to teach him the ways of God. We do not know for sure who was responsible for this part of his education (it may have been Hilkiah, the high priest), but Josiah is receptive to it (II Chronicles 34:3-5).
Mike Ford
Josiah