Hiccups are an reflex that involves involuntary contraction of the diaphragm, causing a rush of air and the typical "hic" noise. In most cases they are totally benign and do not require any medical treatment. They are not related to the stomach muscles, but rather to the diaphragm.
Why hiccups occur exactly is not always clear. It is hypothesized that it may have to due with stimulation of the nerves inside the abdomen, such as from stomach irritation or distention, leading to reflex activation of the diaphragm to contract.
Treatment of attacks of hiccups focuses on eliminating the causes of "irritation" that may stimulate the attacks. Common causes include overeating, drinking alcohol or carbonated beverages, and eating spicy foods.
Occasionally cases of intractable hiccups are due to a serious medical problem such as an infection, a tumor, or an electrolyte imbalance. Although this is very rare, it is probably worth seeing your primary care doctor
for a basic checkup if the attacks continue despite following the basic advice above.
Hiccups are rarely treated with medications unless the attacks last for a very long time. For example, having a few hiccups that go away and then recur a while later would not be an indication for taking a medication. Please see your doctor.