Abstract Background Self-medication with over-the-counter (OTC) drugs is an important public health concern, especially in the vulnerable population of pregnant women due to potential risks to both the mother and fetus. Few studies have studied how factors, such as knowledge, affect self-medication. This study investigated self-medication and its associated factors among pregnant women attending healthcare services in Malang, Indonesia. Methods A cross-sectional study was conducted from July to September 2018 in five healthcare services. A self-administered questionnaire was used and the data were analyzed using multiple regression models. Results Of 333 female participants, 39 (11.7%) used OTC medication. Women with a higher level of knowledge of OTC medication were more likely to self-medicate—adjusted odds ratio (aOR) = 2.15, 95% confidence interval (CI) = 1.03–4.46. Compared with those with less knowledge, pregnant women with more correct knowledge of the possible risk of self-medication were less likely to self-medicate—aOR = 0.29; 95% CI = 0.14–0.60. The effect of a higher level of knowledge of OTC medication was significant among women who had middle school and lower education—aOR = 8.18; 95% CI = 1.70–39.35. The effect of correct knowledge on the possible risks of self-medication was significant only among women with high school and higher education—aOR = 0.17; 95% CI = 0.07–0.42. Conclusion Imparting specific knowledge of the potential risks of using non-prescribed medication during pregnancy may help pregnant women navigate and more safely manage their OTC use. We also suggest further collecting data from more healthcare services, such as hospitals, to obtain more findings generalizable to the Indonesian community.