Graham Woodworth, 38, a former navy commander, was also dismissed from the service after he falsely claimed for boarding school allowances for his three children.
The court at HMS Nelson, Portsmouth, was told that the officer, who served on the aircraft carrier HMS Ark Royal and at the Ministry of Defence Institute in London, became addicted to betting on horses during a student summer in a bookmaker's.
Lt Cdr John Flanaghan, for the prosecution, said that Woodworth, from Portsmouth, had misapplied pounds 12,462 in boarding school allowances paid to him to help fund the education of his children, Stuart, Dale and Angela.
Lt Cdr Flanaghan said Woodworth had also stolen pounds 2,655.12 paid as a lodging allowance. He was supposed to be living at a house in Muswell Hill, north London, while working at the Institute of Naval Oceanography and Meteorology, but was instead commuting from his Portsmouth home.
Investigators were alerted when Woodworth failed to show up for work one day. They went to the address in Muswell Hill but found Woodworth had not lived there for some time, and when they interviewed him about the matter they found discrepancies with his allowances.
Woodworth also falsified receipts from boarding schools in Ardingly, Sussex and Bemridge, Isle of Wight, where his three children were being educated, to claim advance payment of school fees totalling pounds 5,970.
Woodworth pleaded guilty to one charge of theft, four charges brought under the Naval Discipline Act of misapplying school allowances, two charges of false remittance advice for the two schools and an eighth count of allowing a lodger to stay in his Portsmouth naval married quarters without official permission.
For the defence, Mr Bradley Albuery said Woodworth's gambling problems stemmed from his family, who were left homeless 35 years ago because of his father's betting addiction.
"It was like a drug addiction, and looking back over the last five or six years he is now aware how serious a problem he had. He started as a social gambler and it became a compulsion," said Mr Albuery.
Although his client was attending Gamblers Anonymous, Mr Albuery said of the problem: "It is like a drink problem - he fears could come back to haunt him and he accepts he still has a problem."
Mr Albuery said Woodworth was described by colleagues and fellow officers as a "high-flier who had the naval world at his feet". But he had allowed his career to be blighted by his gambling addiction.
President of the court martial, Captain Simon Goodall, told him: "There's no disguising the fact that you are the architect of your own downfall. You have woven a web of deceit which has entangled your entire family and other unsuspecting people.
"The root cause has been your addiction to gambling but this does not alter the stark fact that you have been dishonest. The service relies on honesty and trust and you have abused that trust."
Woodworth was also ordered to have his pay stopped until he had repaid pounds 2,655 and to suffer the financial penalties from his dismissal. They include his pounds 43,000-a-year salary, his married quarters in Portsmouth and a pounds 100,000 pension lump sum.