Dilated cardiomyopathy (DCM) is characterized by immune cell infiltration and can readily progress to heart failure (HF). In the study, differential expression analysis, enrichment analysis, and protein–protein interaction (PPI) network analysis were performed on DCM with HF-related datasets. The CytoHubba was used to identify hub genes. Diagnostic biomarkers were obtained by validating their expression and diagnostic value in another external dataset, and a diagnostic model was constructed. Finally, single-sample gene set enrichment analysis (ssGSEA) was used to predict immune cell infiltration in cardiac samples. The associations between diagnostic biomarkers and immune cells were investigated. The NetworkAnalyst and miRDB databases were used to predict transcription factors and microRNAs, followed by establishing regulatory networks. The DSigDB database was used to predict drug candidates. Subsequently, a mouse model of DCM with HF was used to validate the expression levels of these genes. The present study revealed that differentially expressed genes were enriched in the extracellular matrix organization, cardiac muscle hypertrophy, and other immune-related biological processes. OMD and THBS4 were finally identified, and the nomogram has satisfactory prediction and strong calibration ability. In addition, the two diagnostic biomarkers exhibited significant associations with multiple immune infiltrating cells. Finally, two TFs, 65 microRNAs, and 10 drug candidates were obtained. In animal experiments, two diagnostic biomarkers showed expression trends consistent with the results of bioinformatic analysis. OMD and THBS4 have been identified as hub immune-related diagnostic biomarkers for DCM with HF. Our research provides novel insights into the diagnosis and treatment of the disease.