Organohalogens, a class of molecules that contain at least one halogen atom bonded to carbon, are abundant on the Earth where they are mainly produced through industrial and biological processes1. Consequently, they have been proposed as biomarkers in the search for life on exoplanets2. Simple halogen hydrides have been detected in interstellar sources and in comets, but the presence and possible incorporation of more complex halogen-containing molecules such as organohalogens into planet-forming regions is uncertain3,4. Here we report the interstellar detection of two isotopologues of the organohalogen CH3Cl and put some constraints on CH3F in the gas surrounding the low-mass protostar IRAS 16293-2422, using the Atacama Large Millimeter/submillimeter Array (ALMA). We also find CH3Cl in the coma of comet 67P/Churyumov-Gerasimenko (67P/C-G) by using the Rosetta Orbiter Spectrometer for Ion and Neutral Analysis (ROSINA) instrument. The detections reveal an efficient pre-planetary formation pathway of organohalogens. Cometary impacts may deliver these species to young planets and should thus be included as a potential abiotical production source when interpreting future organohalogen detections in atmospheres of rocky planets.