The Prime Minister will be hosting delegates from the two countries later this week, and the incident as he spoke with the Queen at an event to mark her 90th birthday will be a source of acute embarrassment.
During the summit, Nigeria's President Muhammadu Buhari is scheduled to deliver a keynote address entitled: "Why We Must Tackle Corruption Together".
Mr Cameron could be heard singling out the two states as “possibly the two most corrupt countries in the world”, in footage on ITV News showing him chatting in a group including the Archbishop of Canterbury and Commons Speaker John Bercow.
The Prime Minister told the Queen: “We had a very successful cabinet meeting this morning to talk about our anti-corruption summit, we’ve got the Nigerians… actually we’ve got the leaders of some fantastically corrupt countries coming to Britain.
“Nigeria and Afghanistan, possibly the two most corrupt countries in the world.”
The Archbishop - The Most Rev Justin Welby - is heard to intervene to make clear that "this particular president" is not himself corrupt.
It is not the first time a controversial comment has been overheard in a conversation involving Mr Cameron and the Queen.
In the aftermath of the Scottish independence referendum in 2014, the Prime Minister was heard saying the Queen “purred down the line” when he informed her of the result.
A spokesperson for Downing Street declined to comment directly on Tuesday's conversation, but did point out that the leaders of both Nigeria and Afghanistan have themselves spoken about the scale of their corruption problems.
Afghanistan's Ashraf Ghani and Nigeria's Mr Buhari have written essays for a book accompanying the summit.
Mr Ghani, Number 10 said, acknowledges in his piece that Afghanistan is “one of the most corrupt countries on earth” and Mr Buhari that corruption became a “way of life” in his country under “supposedly accountable democratic governments”.
Anti-corruption movement Transparency International ranked Afghanistan as 166th and Nigeria 136th out of 168 countries and territories in its Corruption Perceptions Index for 2015.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies