This is a very interesting thing to have noticed, and it is difficult to know if this is related to anything specific without knowing more about your medical history and doing a physical exam. In the absence of other symptoms, and knowing that you only have issues with coughing when you eat specific foods, it is unlikely to be related to any significant abnormality.
Additionally, it is comforting that this has not gotten worse over the years that you have had this complaint. The cough receptor is a complex but well understood phenomena designed to protect your lungs from something that your body perceives to be a threat. For some reason, it appears that chocolate and some types of gum are of concern to your lungs. It is possible that increased salivation at the approach of gum or chocolate causes you to feel the need to clear your throat, but that would generally not lead to a "fit" of coughing. While a possibility, it is also not likely to be an allergy, as the effect is very sudden and allergies are usually not instantaneous (and also usually have more symptoms than a simple cough).
f the problem persists, is associated with other symptoms such as a sore throat or weight loss
, or interferes with your life in any way, please see an otolaryngologist
(ear-nose and throat surgeon
) for more help and a focused physical examination.