For some reason the liquid has gone down the trachea rather than the oesophagus. The coughing is initially an involuntary response by your body to try and remove this liquid from your airways and prevent it reaching the lungs as it impinges on the ability of your lungs to function properly. Aspiration of liquid into the lungs can be highly dangerous and cause chest infections and even pneumonia. Luckily most people are in good enough physical shape to remove this liquid from the trachea or bronchus before it actually reaches the lungs, however the elderly, acutely ill and people with a compromised swallowing mechanism (as a result of a stroke for instance) are often unable to expectorate this liquid resulting in a number of deaths from chest infections. Chest infections can also of course be caused by viral and bacterial infections.
Is this the kind of information you are after or are you more specifically wanting to know about the automatic response and how the brain deals with it?