The temperature of the oxygen core of SN 1987A is calculated by analyzing the processes that heat and cool the gas and the processes that form and destroy carbon monoxide. The heating efficiency is calculated by including the processes by which the energetic electrons created by the radioactive decay of 56Co lose energy in a mixed gas of O, C, and CO. The effects of nonuniform energy distribution in the supernova ejecta at early times due to the large optical depths of the y-rays are studied by reducing the energy input rate to match the observed emission of CO. The oxygen core contains a cold CO-emitting region which is effectively cooled by the vibrational emission of CO and heated by the O and C, and a hot O-emitting region which contains neither CO nor SiO and is cooled by the metastable transitions of O. The temperature in the CO- emitting region is constant at about 1800 K in the first year and drops to 700 K at 800 days, consistent with that derived from the observed spectral shapes of the CO emission. The temperature in the O-emitting region is relatively high. It ranges from 4800 K at 100 days to 2200 K at 800 days, in agreement with that derived from the observations of the [O I] λλ6300 6364. The mass of CO predicted by the thermal-chemical model and the mass derived from the observations agree well provided no microscopic mixing of helium is permitted into the oxygen core.