Osteoporosis is usually caused by excessive bone resorption and energy metabolism plays a critical role in the development of osteoporosis. However, little is known about the role of energy metabolism-related genes in osteoporosis. This study aimed to explore the important energy metabolism-related genes involved in the development of osteoporosis and develop a diagnosis signature for osteoporosis. The GSE56814, GSE62402, and GSE7158 datasets were downloaded from the NCBI Gene Expression Omnibus. The intersection of differentially expressed genes between high and low levels of body mineral density (BMD) and genes related to energy metabolism were screened as differentially expressed energy metabolism genes (DE-EMGs). Subsequently, a DE-EMG-based diagnostic model was constructed and differential expression of genes in the model was validated by RT-qPCR. Furthermore, a receiver operating characteristic curve and nomogram model were constructed to evaluate the predictive ability of the diagnostic model. Finally, the immune cell types in the merged samples and networks associated with the selected optimal DE-EMGs were constructed. A total of 72 overlapped genes were selected as DE-EMGs, and a five DE-EMG based diagnostic model consisting B4GALT4, ADH4, ACAD11, B4GALT2, and PPP1R3C was established. The areas under the curve of the five genes in the merged training dataset and B4GALT2 in the validation dataset were 0.784 and 0.790, respectively. Moreover, good prognostic prediction ability was observed using the nomogram model (C index = 0.9201; P = 5.507e−14). Significant differences were observed in five immune cell types between the high- and low-BMD groups. These included central memory, effector memory, and activated CD8 T cells, as well as regulatory T cells and activated B cells. A network related to DE-EMGs was constructed, including hsa-miR-23b-3p, DANCR, 17 small-molecule drugs, and two Kyoto Encyclopedia of Genes and Genomes pathways, including metabolic pathways and pyruvate metabolism. Our findings highlighted the important roles of DE-EMGs in the development of osteoporosis. Furthermore, the DANCR/hsa-miR-23b-3p/B4GALT4 axis might provide novel molecular insights into the process of osteoporosis development.