The UK prime minister said he raised the issue with some of the states involved at the Commonwealth Heads of Government Meeting in Perth, Australia.
Human rights reform in the Commonwealth was one issue that leaders failed to reach agreement on at the summit.
Mr. Cameron says those receiving UK aid should "adhere to proper human rights".
Ending the bans on homosexuality was one of the recommendations of an internal report into the future relevance of the Commonwealth.
Mr. Cameron's threat applies only to one type of bilateral aid known as general budget support, and would not reduce the overall amount of aid to any one country.
Malawi has already had some of its budget support suspended over concerns about its attitude to gay rights. Concerns have also been raised with the governments of Uganda and Ghana.
Mr. Cameron told BBC One's Andrew Marr Show that "British aid should have more strings attached".
But he conceded that countries could not change immediately, and cautioned that there would be a "journey".
"This is an issue where we are pushing for movement, we are prepared to put some money behind what we believe. But I'm afraid that you can't expect countries to change overnight.
"Britain is one of the premier aid givers in the world. We want to see countries that receive our aid adhering to proper human rights.
Watch David Cameron's interview with Andrew Marr on Sunday 30 October 2011 at 09:00 on BBC Two
"We are saying that is one of the things that determine our aid policy, and there have been particularly bad examples where we have taken action."
Mr. Cameron said he had spoken with "a number of African countries" and that more pressure had been applied by Foreign Secretary William Hague, who deputised for him during parts of the summit.
Some 41 nations within the 54-member Commonwealth have laws banning homosexuality. Many of these laws are a legacy of British Empire laws.
The discussion in the Ugandan parliament of an anti-homosexuality bill in 2009 sparked particular controversy, and earlier this year Ugandan gay rights campaigner David Kato was beaten to death in a suspected hate crime.
Nigeria's Senate is currently discussing a bill banning same-sex marriage that includes penalties for anyone witnessing or aiding a same-sex marriage.
A spokesman for the Department for International Development said that budget support, which accounts for about 5% of the UK's annual aid budget of £7.46bn, is conditional direct assistance to governments. To qualify, recipients must adhere to rules on poverty reduction, respect of human rights, good governance and domestic accountability.
Malawi recently had £19m of budget support suspended following various infractions including poor progress on human rights and media freedoms and concern over the government's approach to gay rights, the DfID spokesman said.
Reacting to the news, Uganda Radio Network journalist, Charles Odongpho, said he was puzzled by the move.
"I welcome any move to pressure our government to be respectful of democratic values and human rights but speaking as a Ugandan I think we have much more important issues to deal with than the rights of homosexuals.
"This is your money and you know where you want to put it but we face very serious issues of corruption, poverty, education and hunger. These are the most critical issues for us, not homosexual rights."
Appointing a human rights commissioner to address this and other human rights issues was one of the 100-plus recommendations of the internal report, by the Commonwealth Eminent Persons Group, which includes former UK foreign secretary Sir Malcolm Rifkind.
However, objections from a number of countries blocked adoption of the recommendation, according to Australia's Prime Minister Julia Gillard, speaking at the end of the three-day summit in Western Australia.
Besides the homosexuality rights issue, Sri Lanka's human rights conduct also came under scrutiny at the summit. The country will host the next head of government's meeting in two years' time.
Sri Lanka's army has been accused of war crimes during the civil war with the Tamil Tigers.
Canadian Prime Minister Stephen Harper has said he will boycott the 2013 summit unless there are major reforms in the country.
In earlier comments, Mr. Cameron said there had to be a "proper, independent exercise to look into the whole issue of what happened, and whether there were war crimes, and who is responsible" in Sri Lanka.
BBC correspondent Nicholas Witchell said the summit had been seen as a "watershed" for the organisation as it "struggles to demonstrate its relevance, particularly on human rights".
Though the summit agreed to draw up a written charter and strengthen its ministerial action group, our correspondent said the outcome will be viewed by many "as a disappointing one and an opportunity missed".
Two other developments came from the summit - a reform of royal succession and action on polio.
It was agreed that sons and daughters of any future UK monarch would have equal right to the throne. They will also be allowed to marry Roman Catholics without giving up a claim to the throne.
The move was agreed by the 15 Commonwealth realms where the monarch is head of state.
And Mr Cameron joined the leaders of Canada, Australia and Nigeria, in committing tens of millions of pounds towards eradicating polio in India, Pakistan, Afghanistan and Nigeria.
The campaign will be supported financially by Microsoft magnate Bill Gates.