This study aims to investigate the significant relationship between serum heavy metals (lead [Pb], cadmium [Cd], mercury [Hg]) and the risk of herpes simplex virus type 1 (HSV‐1) infection. Data were derived from the National Health and Nutrition Examination Survey (NHANES) conducted in the United States from 2007 to 2016. This nationally representative survey, conducted by the National Center for Health Statistics, assessed the health status of participants through interviews, physical examinations, and laboratory tests. After excluding participants lacking serum Pb, Cd, and Hg data, as well as those missing HSV‐1 testing data and pregnant women, the analysis included 13 772 participants, among whom 3363 were adolescents. A survey‐weighted multivariate logistic regression model was used to evaluate the association between heavy metal exposure and the risk of HSV‐1 infection, and to explore the dose–response relationship between them. In adults and adolescents, serum concentrations of Pb and Cd were higher in those infected with HSV‐1 than in those not infected. However, an increase in serum Hg concentration was observed only in infected adolescents. After adjusting for potential confounders, elevated serum Pb and Cd concentrations in adults were associated with an increased risk of HSV‐1 infection. Higher serum Pb and Cd concentrations were associated with an increased risk of HSV‐2 infection, irrespective of HSV‐1 infection status. In adults, serum concentrations of Pb and Hg showed an approximately linear relationship with HSV‐1 infection risk (p for nonlinearity > 0.05), whereas the dose–response relationship between serum Cd concentration and HSV‐1 infection was nonlinear (p for nonlinearity = 0.004). In adolescents, serum concentrations of heavy metals (Pb, Cd, Hg) showed an approximately linear relationship with HSV‐1 infection (p for nonlinearity > 0.05). Furthermore, the study examined the relationship between serum heavy metal levels and the risk of HSV‐1 infection across different genders, races, income levels, weight statuses, and immune statuses. In conclusion, there is a significant association between serum heavy metal concentrations and HSV‐1 infection, which warrants further investigation into the causal relationship between them.