The Afghan government said that Michael Semple, the acting European Union mission head, and Marvin Patterson, a senior UN official, held an illegal meeting with Taliban members.
The pair have been told to leave by Thursday.
The government accused them of holding talks with Taliban members in Helmand province.
The Afghan official said: "Not only did they hold talks with the Taliban, but also had given them money.
"It is not clear whether they were supporting the insurgency or not."
He said it was unknown if the meeting was an official or personal initiative but 50 Afghans - including colleagues of the pair - have been arrested due to their links to the incident.
Aleem Siddique, a UN spokesman, said the men visited the town of Musa Qala in Helmand province, recently recaptured by US-led forces after 10 months under Taliban control.
"We do not talk to the Taliban - full stop. That is not what we were in Helmand province to do."
Siddique said the men assessed the "stabilisation" efforts after the military offensive, and spoke to a number of locals including "people who are perhaps undecided whether they are supportive of the government of Afghanistan".
"We have subsequently been informed that our presence in Helmand was detrimental to national security interests. We disagree with this assessment," he said.
"We view this as a misunderstanding between us and the government of Afghanistan."
Both men have extensive experience of working in Afghanistan and are experts in local languages and customs.
Siddique said that Patterson would leave in the next 48 hours but that the organisation was hopeful of his swift return.
The EU could not be reached for comment.
Both the EU and UN are central in the British-led efforts to eradicate poppy production in Afghanistan, which provides for over 90 per cent of the world's heroin.
The industry is said by analysts to be the primary reason for the Taliban's resurgence in the south and east.