"The consequences of this have become clearer in recent days," he said, adding: "I am very sorry for this."
Philip Hammond, the low-key Conservative former transport minister, was named as Fox's replacement.
Cameron said Fox had helped prevent Libyans being "massacred" by Moamer Kadhafi's forces and had done a "superb job" since the Conservative-Liberal Democrat coalition came to power after last year's general election.
With rumours swirling about the nature of Fox's relationship with his 34-year-old former flatmate, Fox apologised to parliament this week and admitted Werritty had accompanied him on 18 foreign trips since he became minister, including a high-profile visit to Sri Lanka.
Werritty also visited Fox 22 times at the Ministry of Defence (MoD) in London and carried business cards describing himself as Fox's adviser despite having no official government role.
But the killer blow came on Friday with reports that financial backers linked to Israel and a private security firm had funded Werritty's first-class travel and hotel stays during his time with the minister.
Werritty was interviewed for a second time on Friday by civil servants as part of an inquiry ordered by Cameron last week into whether Fox broke the ministerial code of conduct, a government source told AFP.
The results of the inquiry are expected next week.
Fox said in his letter to Cameron he had "repeatedly said that the national interest must always come before personal interest. I now have to hold myself to my own standard".
Cameron thanked Fox -- Britain's sixth defence minister in ten years -- for overseeing "fundamental changes" at the bloated MoD and in modernising the armed forces as part of wider government cost-cutting.
"I understand your reasons for deciding to resign as defence secretary, although I am very sorry to see you go," the premier wrote.
"On Libya, you played a key role in the campaign to stop people being massacred by the Kadhafi regime and instead win their freedom."
But the main opposition Labour party said there were still questions to be answered.
"Throughout these events I haven't called for Liam Fox's resignation but just the full truth," said Labour's defence spokesman Jim Murphy.
"Governments must have rules and ministers must have standards. Liam Fox fell foul of the standards and he broke the rules."
Fox, who rose from humble beginnings on a Scottish social housing estate to become a doctor before entering politics, was one of the Conservative party's last heirs of hardline former prime minister Margaret Thatcher.
He lost to Cameron in the 2005 party leadership election, but remained a strong voice for its eurosceptic, American-leaning right and the prime minister had apparently been loath to kick him out too soon.
Fox married his wife, Jesme Baird, the same year and Werritty was best man. Pictures of the grinning pair in matching outfits have been splashed over the press.
Fox is the first Conservative minister to resign from the government and the second cabinet minister, following Liberal Democrat Chief Secretary to the Treasury David Laws.
Laws quit days after the election over claims that he fiddled his expenses.
The Guardian newspaper first raised questions about Fox's ties to Werritty in August and the scandal erupted earlier this week with fresh revelations about their travels together.
Then on Friday the Times reported that donors funnelled £147,000 ($231,000, 167,000 euros) into a not-for-profit company established by Werritty, called Pargav, to pay for his first class flights and upscale hotels.
Later Friday a venture capitalist, Jon Moulton, said Fox had personally approached him to donate to Pargav.