Necrophoric behaviour is critical sanitation behaviour in social insects. However, little is known about the necrophoric responses of workers towards different developmental stages in a colony as well as its underlying mechanism. Here, we show that Solenopsis invicta workers display distinct necrophoric responses to corpses of workers and pupae. Corpses of workers killed by freezing (dead for <1 h) were carried to a refuse pile, but pupal corpses would take at least 1 day to elicit workers’ necrophoric response. Metarhizium anisopliae-infected pupal corpses accelerated the necrophoric behaviour of resident workers, with 47.5% of unaffected corpses and 73.8% infected corpses discarded by 1 day post-treatment). We found that fungus-infected pupal corpses had a higher concentration of fatty acids (palmitic acid, oleic acid and linoleic acid) on their surface. We experimentally confirmed that linoleic and oleic acids would elicit a necrophoric response in workers. The appearance of linoleic and oleic acids appeared to be chemical signals involved in recognition of pupal corpses, and M. anisopliae infection could promote the accumulation of fatty acids on surface of pupal corpses resulting in accelerated necrophoric responses of workers.