How does your body know when it is infected so it can invoke a fever?
During infection certain macromolecules present in the pathogens (pathogen associated molecular patterns) such as lipopolysaccharide launch the innate immune response, through toll like receptors. This leads to production of pro-inflammatory cytokines and also other inflammatory mediators like prostaglandins, thereby causing inflammation and fever.