Quite early on. I put out some information on this topic that you might be interested in in this thread, and I'll be using the same source here.
Jernegan is an old historian, publishing in the early 20^th century. It's a bit out dated, but since this is more of a factual answer than an interpretive one, it should be OK.
Compulsory education was recognised as a necessity because without it, children could not be expected to know either religion or law. Official guidelines on education said that children must be literate to the level of being able "to read and understand the principles of religion and the capital laws of the country", giving them both civic standing, and religious standing.
As with most legal issues in the United States, they were adapted in a staggered manner, with all deliberate speed(ha). In this case it was also because of the formation of certain states being earlier than others.
First to legislate compulsory education, and therefore literacy, was Massachusetts in 1642. However, this was only for children, and if they were not literate they were to be apprenticed. Apprentices were not required to learn to read. That was amended in 1648.
Connecticut followed Massachusetts in 1650, the New Haven Colony in 1655(it was combined with Connecticut in 1665, but had passed legislation in its own right). None of New Hampshire, Maine, or Rhode Island passed legislation before 1700, but due to issues of jurisdiction, both New Hampshire and Maine were subject to Massachusetts law for a period, and by 1671, "all of the territory of New England, with the exception of Rhode Island, was under a system of compulsory education", which is really quite a wonderful thing.
In the South, Virginia passed laws as early as 1642, but these laws were for "special classes" of child. The three classes were orphaned children, poor children, and illegitimate children. The first law in 1642 was only with regards to orphans, and was not comprehensive as it only required self reporting on educational status by guardians. In 1656 this was amended obliging Justices to inquire into the status of orphan education. For poor children in Virginia, there were at least 8 laws passed between 1646 and 1769 on the matter of compulsory education.
These laws specifically targeted children who were not capable of being educated by their families - either for reasons of absence or poverty. From this we can see that literacy was expected from the 17^th century onwards in the colonies. Once the United States was formed, this expectation would have been shifted to the other states as they joined the union.
Lastly, it needs to be remembered that it was illegal to teach slaves to read and write. This fact both reinforces the notion of the importance of literacy, as well as showing that education was desirable while only being available to citizens. Later of course, great emphasis would be put on education by freed slaves and their children because it was a significant division between them and the white American population.
Source:
Marcus W. Jernegan, 'Compulsory Education in the American Colonies: I. New England', The School Review, found at Jstor.