A heteroatom is any atom that is not carbon or hydrogen. Usually, the term is used to indicate that non-carbon atoms have replaced carbon in the backbone of the molecular structure. Typical heteroatoms are nitrogen, oxygen, sulphur, phosphorus, chlorine, bromine, iodine.
In chloromethane ,chlorine is the heteroatom whereas in ethanoic acid , oxygen is the heteroatom.