In general, never trust words in the English language to be phonetic! This is largely a consequence of English being such a fast-evolving language, and importantly, owing its vocabulary to many linguistic sources: Latin, Old French, Anglo-Saxon (a.k.a. Old English), Norse, and many others.
In this case it seems we have French to thank. This etymology is given online, and explains the supposed strange pronunciation:
debt
late 13c., dette, from O.Fr. dete, from L. debitum “thing owed”, neut. pp. of debere “to owe”, originally, “keep something away from someone”, from de- “away” (see de-) + habere “to have” (see habit). Restored spelling after c.1400.
In other words, debt comes via the Old French dete, which itself derives from classical Latin debitum. The b sound got lost due to French phonological rules/convention, and hence the French-origin pronunciation in English. Evidently, after the end of the Middle Ages in the 15th century, there was much revived interest in the classical world, and the spelling reverted to include the original b. Pronunciation, of course, stayed the same.
(Note that this sort of evolution occurred with many different English words, and occurred at the same time many new Latin words entered the English language.)
A few sources indicate it's due to initial confusion between coco, cocoa, and cocao.
According to Dictionary.com, the confusion started circa 1545 when cocao was misspelled as cocoa.
But, according to the Online Etymology Dictionary, the pronunciation issue occurred with the 1707 printing of Johnson's Dictionary that ran coco next to cocoa, stirring confusion between the two words.
Best Answer
It's associated with the `Great Vowel Shift'. I found this on Hartford Courant, citing a letter from James McCawley (professor of linguistics at the University of Chicago at the time, I think currently acknowledged as the expert in his field) in a letter to language columnist William Safire (also highly regarded, but not really in the same league)...
I really don't think I could add anything to such an eloquent summary.