Context. Ethylene oxide (c-C 2 H 4 O), and its isomer acetaldehyde (CH 3 CHO), are important complex organic molecules because of their potential role in the formation of amino acids. The discovery of ethylene oxide in hot cores suggests the presence of ring-shaped molecules with more than 3 carbon atoms such as furan (c-C 4 H 4 O), to which ribose, the sugar found in DNA, is closely related. Aims. Despite the fact that acetaldehyde is ubiquitous in the interstellar medium, ethylene oxide has not yet been detected in cold sources. We aim to understand the chemistry of the formation and loss of ethylene oxide in hot and cold interstellar objects (i) by including in a revised gas-grain network some recent experimental results on grain surfaces and (ii) by comparison with the chemical behaviour of its isomer, acetaldehyde. Methods. We introduce a complete chemical network for ethylene oxide using a revised gas-grain chemical model. We test the code for the case of a hot core. The model allows us to predict the gaseous and solid ethylene oxide abundances during a cooling-down phase prior to star formation and during the subsequent warm-up phase. We can therefore predict at what temperatures ethylene oxide forms on grain surfaces and at what temperature it starts to desorb into the gas phase. Results. The model reproduces the observed gaseous abundances of ethylene oxide and acetaldehyde towards high-mass star-forming regions. In addition, our results show that ethylene oxide may be present in outer and cooler regions of hot cores where its isomer has already been detected. Our new results are compared with previous results, which focused on the formation of ethylene oxide only. Conclusions. Despite their different chemical structures, the chemistry of ethylene oxide is coupled to that of acetaldehyde, suggesting that acetaldehyde may be used as a tracer for ethylene oxide towards cold cores.