He said he would require ministers and civil servants to record all meetings with newspaper and media proprietors, senior editors and executives.
Labour leader Ed Miliband said he hoped it would be "retrospective" back to the 2010 election.
He again attacked Mr Cameron about his decision to hire Andy Coulson at No 10.
The issue came up at a fiery Prime Minister's Questions ahead of a statement in which Mr Cameron gave more details of a proposed inquiry into phone hacking.
MPs were due to debate calls for News Corporation to withdraw its bid to fully take over BSkyB - but the company withdrew it shortly beforehand saying it was "too difficult to progress in this climate".
It follows allegations that the phones of murdered schoolgirl Milly Dowler, the families of the Soham murder victims and of British soldiers killed in action, had been hacked.
Former PMs Tony Blair and Gordon Brown have both faced Freedom of Information requests over their meetings with News Corporation boss Rupert Murdoch and Mr Cameron has also faced headlines about his "secret meetings" with Mr Murdoch.
At PMQs on Wednesday, he said what had happened at News International - News Corporation's UK arm - was "disgraceful" and the company should "stop thinking about mergers when they've got to sort out the mess they have created".
But he added: "If we are going to say to the police 'you must be more transparent and cut out corruption', if we are going to say to the media 'you must be more transparent and cut out this malpractice' then, yes, the relationship between politicians and the media must change and we must be more transparent too about meetings."
He said politicians had been "too silent" about media tactics in the past: "That is part of the problem. Your bins are gone through by some media organisation but you hold back from dealing with it because you want good relations with the media.
"What we need is some honesty about this issue on cross-party basis so we can take on this problem."
The prime minister's official spokesman said Mirror Group reporters had gone through Mr Cameron's bins when he was in opposition.
In his statement to MPs later, he said he would consult Cabinet Secretary Sir Gus O'Donnell about amending the ministerial code "to require ministers to record all meetings with newspaper and other media proprietors, senior editors and executives - regardless of the nature of the meeting".
Top civil servants and special advisers would also have to record such meetings - and the information would be published quarterly.
Mr Miliband said he welcomed the proposal but added: "I hope and expect he will ensure that that proposal is implemented in a retrospective way back to the last general election."
BBC political editor Nick Robinson said it appeared the change would not mean every meeting with every journalist would have to be recorded - but he said it would allow people to see whether there was a pattern of politicians meeting particular proprietors or newspapers in advance of important decisions.
Mr Miliband also renewed his attack on Mr Cameron for hiring former News of the World editor Andy Coulson as his communications director at No 10. Mr Coulson resigned earlier this year but had denied knowing anything about phone hacking while he was in charge of the newspaper.
There have been reports that the Guardian informed Mr Cameron's aide Steve Hilton over links Mr Coulson reportedly had with private investigator Jonathan Rees - and that Mr Hilton passed on the information to Mr Cameron's chief of staff Ed Llewellyn.
Mr Cameron said: "This information was not passed on to me."
But he added it was not secret information as it had been largely published in the Guardian at the same time, in February 2010, and had "no allegations directly linking Andy Coulson to illegal behaviour".
And the PM said he met Guardian editor Alan Rusbridger the following month - but he had not raised the issue with him.
Mr Miliband said the prime minister should apologise for his "catastrophic error in judgement" in appointing Mr Coulson as his director of communications.
Mr Cameron told MPs he had hired Mr Coulson on the basis of assurances that he did not know about the phone hacking and was not involved in criminality - and he should be "innocent until proven guilty".
But he added: "If it turns out he lied, it won't just be that he shouldn't have been in government, it will be that he should be prosecuted."
The Labour leader said Mr Cameron "just doesn't get it".
But Mr Cameron said he could raise the issue of Mr Miliband's own communications director Tom Baldwin, another former News International journalist, and Gordon Brown's former aide Damian McBride - who resigned over unfounded personal smears made about senior Tories.
Mr Cameron also said News International should have accepted the resignation of its chief executive Rebekah Brooks - who was editor of the News of the World when murdered schoolgirl Milly Dowler's mobile phone was allegedly hacked into. The Labour leader has called for her to quit.
David Cameron has said the relationship between politicians and the media "must change" and pledged to be more open about meetings with media bosses.