The objective of this study is to utilize cost-effective renewable substrates derived from agro-food wastes for the production of biosurfactant by Bacillus megaterium, which was isolated from petroleum sludge. Various agro-food waste materials, namely potato peelings (PP), rice cooking water (RW), biscuit by products (BB), carob pods (CP), and eggshells, were evaluated as nutrient sources for bacterial growth compared to a synthetic medium (SM). The results indicate that the medium comprising carob pods, potato peels supplemented with eggshells promoted the growth of the bacteria and the production of Biosurfactants at a rate of 150 mg/l and 140 mg/l respectively. The biosurfactant exhibited an emulsification index (E24) of 55.23 +/- 0.32%, 46.47 +/- 3% 43.80 +/- 0.4%, 18.33 +/- 0.25% and 20 +/- 0.11% for PP, CP, SM, BB and RW respectively. The biosurfactant produced from PP had the ability to decrease the surface tension of water from 74 to 39.38 mN/m, with a critical micelle concentration (CMC) of 15 mg/L. The chemical characterization of purified biosurfactant was done using Fourier-transform infrared spectroscopy (FTIR) and Thermal gravity (TG), as well as differential scanning calorimetry (DSC) analysis (TG/DSC), revealing the functional groups and thermostability of the biosurfactant. The DSC spectrum for PP biosurfactant showed the highest thermostability with crystalline temperature (Tc) of 150 degrees C and melting point (Tm) of 295 degrees C. The extracted biosurfactant was mixed with petroleum sludge, composed of heavy oil, 40.64 +/- 0.19% of extracted oil was obtained after 5 h of reaction while using PP based medium.