Three people have been arrested, including a man who allegedly confessed to killing her and selling some body parts to a witch doctor for $25 (£18).
He then threw the girl's decapitated body into a well in Idosemo village in Ogun state, a police spokesman said.
Belief in witchcraft or "juju" is widespread in Nigeria.
Traditional witchcraft practitioners are widely consulted for cures for various ailments and because they are believed to have magical powers to protect their clients from a wide range of misfortunes and to bring good luck.
The witch doctor, who is also in detention, has admitted to receiving human body parts, but said he did not contract the killing, police spokesman Abimbola Opeyemi said.
The girl had been selling street snacks when she was attacked, he said.
Her father had reported her missing to local police.
Collaborative work between the police and a local vigilante group led to the arrest of the witch doctor who "confessed under police interrogation" and led police to the well where her body was dumped, Mr Opeyemi said.
The suspects are yet to be charged in court.
It is the latest in a spate of such murders in the south-west of the country.