Mr Duterte said he might ask China and African nations to form another body. He also accused the UN of failing on terrorism, hunger and ending conflicts.
Mr Duterte, elected in May, has sanctioned the killing of traffickers to try to wipe out the drugs trade.
The UN has repeatedly condemned the drive as a violation of human rights.
Some 900 suspected drug traffickers have been killed since Mr Duterte was elected on 9 May.
Last week, two UN human rights experts said Mr Duterte's directive for police and the public to kill suspected drug traffickers amounted to "incitement to violence and killing, a crime under international law".
In an expletives-laden tirade against the UN on Sunday, Mr Duterte branded the experts "stupid", saying they should count the number of innocent lives lost to drugs.
"I do not want to insult you. But maybe we'll just have to decide to separate from the United Nations," he said.
"If you are that rude, we might just as well leave," he said.
"So take us out of your organisation. You have done nothing. Where were you here the last time? Never. Except to criticise," he said.
Mr Duterte said the UN should refund its contribution "so we can go out".
Mr Duterte said the UN had been unable to combat hunger and terrorism and had failed to end the killing of civilians in Iraq and Syria.
"You now, United Nations, if you can say one bad thing about me, I can give 10 [about you]. I tell you, you are [useless]. Because if you are really true to your mandate, you could have stopped all these wars and killings."
UN Secretary General Ban Ki-moon and the UN's Office on Drugs and Crime (UNODC) have both condemned Mr Duterte's "apparent endorsement of extrajudicial killings, which is illegal and a breach of fundamental rights and freedoms".
Mr Duterte was sworn in as president in June, after winning a landslide election victory.
He had previously been mayor of the country's third biggest city, Davao, for 22 years where his tough approach and controversial comments earned him the nickname "The Punisher".