The sperm flagellum is essential for male fertility, and defects in flagellum biogenesis are associated with male infertility. Deficiency of coiled-coil domain-containing (CCDC) 42 (CCDC42) is specifically associated with malformation of mouse sperm flagella. Here, we find that the testis-specific protein CCDC38 interacts with CCDC42, localizing on the manchette and sperm tail during spermiogenesis. Inactivation of CCDC38 in male mice results in a distorted manchette, multiple morphological abnormalities of the flagella of spermatozoa and eventually male sterility. Furthermore, we find that CCDC38 interacts with intraflagellar transport protein 88 (IFT88), as well as outer dense fibrous 2 (ODF2), and the knockout of Ccdc38 reduces transport of ODF2 to the flagellum. Altogether, our results uncover the essential role of CCDC38 in sperm flagellum biogenesis, and suggest that some mutations of these genes might be associated with male infertility in humans.