A heterogeneous base catalyst transesterification process with a calcium oxide (CaO) catalyst was performed to produce high-purity methyl ester (ME) from pretreated sludge palm oil (PSPO) derived from sludge palm oil (SPO). Additionally, a comparative analysis was conducted with potassium hydroxide (KOH) as a homogeneous base catalyst to assess the distinctions between heterogeneous and homogeneous base catalysts. The response surface methodology (RSM) was utilized to determine the optimal and recommended conditions for both transesterification processes. For heterogeneous transesterification, a varying CaO catalyst loading (10–60 wt.%), methanol (25–65 wt.%), and reaction time (60–180 min) were essential parameters. Meanwhile, homogeneous transesterification involved investigating the KOH catalyst loading (1–3 wt.%), methanol (1.8–5.5 wt.%), and reaction time (20–60 min). For the heterogeneous-base-catalyzed reaction, the recommended conditions were as follows: a molar ratio of methanol to oil of 5.83:1 (41.61 wt.%), 31.3 wt.% CaO, and a reaction time of 119.0 min, which resulted in a ME purity of 96.51 wt.%. The optimal conditions for homogeneous transesterification were a molar ratio of methanol to oil of 0.49:1 (3.45 wt.%), a 40 min reaction time, and a 1.39 wt.% KOH concentration, which achieved 96.59 wt.% ME and met the standard.