You can find Marx's discussion in Volume I of Theories of Surplus Value, starting about p. 390 (Progress Publishers, 1962-4. Sorry I don't have that with me to be more precise), and in Vol.I of Capital, Part V, Chapter XVI, where, for example, you will find this passage:
If we may take an example from outside the sphere of production of material objects, a schoolmaster is a productive labourer, when, in addition to belabouring the heads of his scholars, he works like a horse to enrich the school proprietors. That the latter has laid out his capital in a teaching factory, does not alter the relation (p.509). As a general matter, Volume I of Capital discusses productive labor in the production process, Vol. 2 covers productive labor in circulation, and like with all topics, Vol. 3 ties things for the process as a whole.
Let me briefly lay out my understanding on the question of teaching and productive labor.
First let's make clear that by productive labor we mean that which produces surplus value for capital. The distinction between productive and unproductive labor has nothing to do with social usefulness. It's easy to think of unproductive work that is more socially useful than productive labor.
There are three kinds of labor in capitalist society: productive, unproductive (each with refence to its relation to capital) and noncapitalist. Marx's statement above has to do with teachers at private, profit making institutions, where teachers do produce surplus value for the owners of those schools. But most teaching in the US is done at public institutions. There, teachers are noncapitalist labor because their work is paid for directly by a tax on realized surplus value (not just profits, BTW) created in the capitalist sector. These teachers' labor is exchanged directly with money; there is no direct relationship with capital.
But teachers indirectly affect the creation of surplus value in the capitalist sector. Their product enters the production cycle as accumulated (work) skills of labor which contribute to an increase in the surplus value created there. In Marxian terms of c+v+s=output, v is determined outside the production system (by the cost of reproducing labor for another round of production) and c is the constant capital used up in production. Therefore, all such enhancements of labor productivity due to learning produce additional surplus value (which does not preclude workers from gaining some of the s in the form of wages above v).
Thus public school teachers, though not productive laborers, (indirectly) add to the mass of surplus value to the extent that the increase in s due to education exceeds the payment out of s to finance the educational system itself. Education subtracts from total s when the opposite is true.
But while most teaching adds skills for use in capitalist production, some does not. And some forms of learning can lead a person to be hostile to capitalist imperatives, as is evident from all of the subversives on this list. From this we derive a general rule: teachers raise labor productivity for use by capital only up to the point where people get smart enough to reject working for capital, and perhaps learn to reject capitalism itself. Now there's a real purpose for teachers, an important goal for all to seek.
>