Occupational health service (OHS) is the main provider of primary care services for the working population in Finland. We investigated whether socioeconomic differences in the utilization of OHS predict sickness absence (SA) due to mental disorders. We used register linkage data covering the employees of the City of Helsinki aged 18–34 years (N = 6545) and 35–54 years (N = 15,296) from 2009 to 2014. The outcome was medically certified long-term (over 11 days) SA due to mental disorders. Cox regression analyses were performed to obtain hazard ratios (HR) and their 95% confidence intervals (CIs). Employees with low socioeconomic position (SEP) used OHS more frequently. The number of OHS visits independently predicted SA due to mental disorders. HRs were 1.59 (95% CI 1.35, 1.86) for those with frequent visits and 1.73 (95% CI 1.30, 2.29) for those with a clustered visit pattern among 18–34 year old employees; and 1.46 (95% CI 1.18, 1.81) and 1.41 (95% CI 1.14, 1.74) among 35–54 year old employees, respectively. In both age groups, lower education and routine non-manual worker position indicated the highest probability of SA. Low SEP predicts both high OHS utilization and subsequent SA due to mental disorders. Medical records may be used to accurately predict future SA, and the results indicate that preventive measures should be targeted particularly to younger employees with lower SEP.