Objective: While prior Epstein–Barr virus (EBV) infection has been consistently associated with subsequent risk of developing multiple sclerosis (MS), the association with other common herpesviruses has been more controversial. Our objectives were to determine whether remote infection with EBV and other common herpesviruses affect the susceptibility to pediatric MS and if there are interactions between genetic and demographic factors and viral infections. Methods: Cases with pediatric-onset MS or clinically isolated syndrome within 4 years of disease onset, and controls were recruited from 16 American pediatric MS centers. Logistic regression models adjusted for potential confounders assessed the association between case status and serological evidence for past infection with EBV, cytomegalovirus (CMV), Herpes Simplex viruses-1 (HSV-1) and -2. We determined the heterogeneity of the effect of viral infection on the risk of having MS according to race, ethnicity and HLA-DRB1:1501 status. Results: A total of 356 pediatric cases and 493 controls were recruited. In multivariable models, EBV-viral capsid antigen (VCA) seropositivity was associated with increased odds of having MS by 7.4 times (95% CI: 4.5–12.0, P < 0.001). Seropositivity for HSV-1 was also associated with increased odds of having MS (OR 1.54, 95% CI: 1.06–2.25, P = 0.025) but this increase was seen only in Whites (OR = 2.18, 95% CI 1.35–3.52, P < 0.001) and those negative for HLA-DRB1*1501 (OR = 1.89, 95% CI 1.17–3.03, P = 0.009). The effect of remote EBV infection on the risk of pediatric MS depended on race and HLA-DRB1*15:01 status. Interpretation: EBV seropositivity is strongly associated with pediatric MS, as is HSV-1 seropositivity in subjects negative for HLA-DRB1*15:01. Our report of interactions between select viral exposures, and age, race and DRB1 status suggests a complex effect of environmental and genetic risk factors on MS development.