I know this problem only too well. In late stage dementia problems swallowing are very common. Nothing much can prevent it as the brain is losing control of coordination and your husband will be swallowing food and liquids and trying to breathe at the same time. You can't stop this happening altogether but you can limit this by not talking while he is drinking, so as he concentrates on drinking rather then replying to you and also make sure he is sitting bolt upright before eating and drinking.
We find drinking through a straw helps, and also cutting food up in to tiny pieces. You can buy gelified water from boots, and if the problem persists you may want to liquidize solid food. Speak to your GP who maybe able to suggest some tips or else I would pay a visit to your local nursing home. They will be very used to dealing with this as parkinsons sufferers often have the same problem.