Macrophages differentiated into a classically activated (M1) or alternatively activated phenotype (M2) in infection and tumor, but the precise effects of glycolysis and oxidative phosphorylation (OXPHOS) metabolic pathway remain unclear. Herein, the effects of glycolysis or OXPHOS on macrophage polarizations were investigated using a pharmacological approach in mice. 2-Deoxy-D-glucose (2-DG) treatments, which blocks the key enzyme hexokinase of glycolysis, efficiently inhibits a specific switch to M1 lineage, decreasing the secretion of pro-inflammatory cytokines and expressions of co-stimulatory molecules associated with relieving infectious inflammation in vitro and in vivo. Glycolytic activation through the hypoxia-inducible factor-1α (HIF-1α) pathway was required for differentiation to the M1 phenotype, which conferred protection against infection. Dimethyl malonate (DMM) treatment, which blocks the key element succinate of OXPHOS, efficiently inhibits a specific switch to M2 lineage when macrophages receiving M2 stimulation, decreasing the secretion of anti-inflammatory cytokine and CD206 expressions. Mitochondrial dynamic alterations including mitochondrial mass, mitochondrial membrane potential (Dym) and ROS productions were critically for differentiation to the M2 phenotype, which conferred protection against anti-tumor immunity. Glycolysis is also required for macrophage M2 differentiation. Thus, these data provide a basis for a comprehensively understanding the role of glycolysis and OXPHOS in macrophage differentiation during anti-infection and anti-tumor inflammation.