Rowling sued Chris Gossage, a partner in the law firm, for revealing to a family friend Rowling had written "The Cuckoo's Calling" under the pen name Robert Galbraith.
The friend then posted the news in a Twitter exchange with a journalist and the story was picked up by media outlets around the world.
The BBC said Gossage and the law firm have formally apologized for the leak, paid for Rowling's legal expenses and made a donation -- the amount of which was not disclosed -- to The Soldiers' Charity, formerly known as the Army Benevolent Fund.
Rowling said she wanted the money to go to the charity "partly as a thank you to the army people" who helped her with research for "The Cuckoo's Calling."
"But also because writing a hero who is a veteran has given me an even greater appreciation and understanding of exactly how much this charity does for ex-servicemen and their families, and how much that support is needed," the BBC quoted her as saying.
The scribe is also donating all her royalties from the book to the organization.
Maj. Gen. Martin Rutledge, chief executive of ABF The Soldiers' Charity, said he is "absolutely thrilled" by the author's "extraordinary generosity."
"This donation will make a huge difference to the lives of thousands of soldiers, former soldiers and their families who are in real need," he said. "Her tremendous show of support for The Soldiers' Charity will help to remind people of the many sacrifices made by our soldiers, long after any news of Afghanistan has left the front page."
Rowling previously penned the Harry Potter blockbuster book series.
NBC reportedly holds celebs hostage to Jimmy Fallon's show
Millions of Getty images now available for free via embed tool