The Prime Minister said the "unacceptable" actions of fundraisers and the organisations employing them was damaging the reputation of the entire charity sector.
The fundraising methods of major charities have come under the spotlight since the death of Bristol poppy seller Olive Cooke in May. At one point the 92-year-old received 267 charity letters in one month, leading to suggestions that the hounding for money pushed her to take her own life.
"Our charities undertake vital work, bringing communities together and providing support to some of the most vulnerable members of our society," said David Cameron
But the conduct of some fundraisers used by them is frankly unacceptable and damages the reputation of the sector as a whole, which is why we're introducing a new law to make sure charities raise funds in the right sort of way."
The new law will force charities and fundraisers to have a written agreement showing how the vulnerable will be protected.
Some of the UK's biggest charities will also be forced to reveal their fundraising methods to show they are behaving properly.
Minister for Civil Society Rob Wilson said: "After the tragic death of Olive Cooke, I made clear that the behaviour of charities had to change or we would take action - today I am delivering on that promise.
"This law will force charities to face up to their responsibilities."
Her family insisted that, while the letters and phone calls were intrusive and a nuisance, the charities were not to blame for Mrs Cooke's death.
In separate allegations, four of the country's biggest charities are being investigated amid claims fundraisers contacted people on the Government's "opt-out" database.
The NSPCC, British Red Cross, Oxfam and Macmillan Cancer Support have been accused of making fundraising calls to people registered with the Telephone Preference Service (TPS), which protects them from receiving unsolicited sales or marketing calls.
The accusations have been made after an undercover reporter with the Daily Mail worked in a call centre fundraising on behalf of the charities.