He told MPs that he does not want Britain to leave, but said that an exit was "imaginable".
In the Commons, Mr Cameron was asked if he could ever imagine Britain quitting the union.
"All futures for Britain are imaginable. We are in charge of own destiny, we can make our own choices," he replied, adding that a British departure was "not my preference".
He said: "I believe the choice we should make is to stay in the EU, to be members of the single market, to maximise our impact in Europe, but where we are unhappy with parts of the relationship we shouldn't be frightened of standing up and saying so."
The remarks are the first in which Mr Cameron has conceded the possibility of Britain leaving an organisation it joined in 1973.
He spoke amid continuing debate in the Conservative Party and across Europe about Britain's future in the EU.
A growing number of Conservative MPs want the party to commit to a referendum that would offer voters a choice between a renegotiated "common market" membership of the EU and outright departure.
Mr Cameron has not yet set out his position on the issue, although he has said that he does not want Britain to leave the EU, warning that the country could end up in a position like that of Norway – bound by EU rules but unable to influence them.
He said he would set out his long-term vision for Britain's relationship with the rest of the EU in a major public speech.
The speech was originally scheduled for the autumn, but has been repeatedly delayed. Mr Cameron told MPs that he would finally deliver the address "in the middle of January".
Mr Cameron's failure to clarify his thinking on the EU has led some European leaders to speculate that Britain could end up leaving.
Ed Miliband, the Labour leader, said Mr Cameron has lost control of Britain's destiny.
"The drift in his party and the direction of his policy mean we are sleepwalking towards exit," he said.
Mr Johnson – seen as a potential future rival to Mr Cameron for the Tory leadership – warned that the government could not put off indefinitely a referendum on Britain's future in the EU.
He said that he would like to see the public given the chance to vote on the issue before the next general election in 2015 although he did not expect it to happen.
"We have never had a popular vote since 1975 on a European question. I would like to be able to campaign for a single market and the withdrawal from a lot of the nonsensical policies," he said.
Mr Johnson added that while he would prefer Britain to remain in the EU, it should be prepared to walk away if it was unable to negotiate a new relationship.
"Don't forget that 15 years ago the entire CBI, British industry, the City – everybody – was prophesying that there would be gigantic mutant rats swarming out of the gutters in the sewer to gnaw the last emaciated faces of the remaining British bankers if we didn't go into the euro."
(© Daily Telegraph, London)