Removing antibiotics from water is critical to prevent the emergence and spread of antibiotic resistance, protect ecosystems, and maintain the effectiveness of these vital medications. The combination of ozone and electrocoagulation in wastewater treatment provides enhanced removal of contaminants, improved disinfection efficiency, and increased overall treatment effectiveness. In this work, the removal of sulfamethoxazole (SMX) from an aqueous solution using an ozone–electrocoagulation (O–EC) system was optimized and modeled. The experiments were designed according to the central composite design. The parameters, including current density, reaction time, pH, and ozone dose affecting the SMX removal efficiency of the OEC system, were optimized using a response surface methodology. The results show that the removal process was accurately predicted by the quadric model. The numerical optimization results show that the optimum conditions were a current density of 33.2 A/m2, a time of 37.8 min, pH of 8.4, and an ozone dose of 0.7 g/h. Under these conditions, the removal efficiency reached 99.65%. A three-layer artificial neural network (ANN) with logsig-purelin transfer functions was used to model the removal process. The data predicted by the ANN model matched well to the experimental data. The calculation of the relative importance showed that pH was the most influential factor, followed by current density, ozone dose, and time. The kinetics of the SMX removal process followed the first-order kinetic model with a rate constant of 0.12 (min−1). The removal mechanism involves various processes such as oxidation and reduction on the surface of electrodes, the reaction between ozone and ferrous ions, degradation of SMX molecules, formation of flocs, and adsorption of species on the flocs. The results obtained in this work indicate that the O–EC system is a potential approach for the removal of antibiotics from water.