Medical oxygen is a critical element in the treatment process of COVID-19 patients which its shortage impacts the treatment process adversely. This study aims to apply machine learning (ML) to predict the requirement for oxygen-based treatment for hospitalized COVID-19 patients. In the first phase, demographic information, symptoms, and patient’s background were extracted from the databases of two local hospitals in Iran, and preprocessing actions were applied. In the second step, the related features were selected. Lastly, five ML models including logistic regression (LR), random forest (RF), XGBoost, C5.0, and neural networks (NNs) were implemented and compared based on their accuracy and capability. Among the variables related to the patient’s background, consuming opium due to the high rate of opium users in Iran was considered in the models. Of the 398 patients included in the study, 112 (28.14%) received oxygen-based treatment. Shortness of breath (71.42%), fever (62.5%), and cough (59.82%) had the highest frequency in patients with oxygen requirements. The most important variables for prediction were shortness of breath, cough, age, and fever. For opioid-addicted patients, in addition to the high mortality rate (23.07%), the rate of oxygen-based treatment was twice as high as non-addicted patients. XGBoost and LR obtained the highest area under the curve with values of 88.7% and 88.3%, respectively. For accuracy, LR and NNs achieved the best and same accuracy (86.42%). This approach provides a tool that accurately predicts the need for oxygen in the treatment process of COVID-19 patients and helps hospital resource management.