This paper develops a labour market model with on-the-job search, match-specific productivity draws and an endogenous irreversible schooling decision. The choice of schooling is modeled as an optimal stopping problem which gives rise to the equilibrium heterogeneity of workers with respect to the formal education. The optimal schooling decision is characterized by the reservation productivity of students which is a monotone function of time. The reservation productivity of high ability students is increasing narrowing the range of acceptable employers in the regular labour market. This mechanism generates a positive sorting of more educated workers to more productive employers. The schooling density is downward-sloping and the equilibrium wage distribution is rightskewed with a unique interior mode. This means that the majority of workers earn wages in the middle range of the earnings distribution. At the same time there is a small proportion of inexperienced unskilled employees in the left tail of the earnings distribution and a small proportion of experienced high-skilled workers in the right tail of the distribution.