This study examined whether coronavirus disease 2019 (COVID-19) infection experience enhances preventive behaviour (i.e., hand disinfection and mask-wearing), with risk perception acting as a mediating factor. The study included participants aged ≥18 years residing in Japan, enrolled in a 30-wave cohort study conducted from January 2020 to March 2024. Using propensity score matching, 135 pairs of participants with and without infection were extracted, adjusting for dread and unknown risk perception, preventive behaviours, sociopsychological variables, and individual attributes. Comparisons of risk perception and preventive behaviour were made between groups post-infection experience, and mediation analysis was conducted to test whether risk perception mediated the effect of infection experience on preventive behaviour. Following the infection experience, participants in the infection group reported significantly higher scores for one item of unknown risk perception and a greater proportion of mask-wearing. The indirect effect of infection experience on mask-wearing, mediated by the unknown risk perception item, was significant. COVID-19 infection experience increased perceptions of unknowable exposure, which in turn promoted mask-wearing behaviour. Incorporating insights from personal infection experiences into public health messaging may enhance risk perception and promote preventive behaviour among non-infected individuals, offering a novel approach to infection control at the population level.