pH-responsive smart materials with switchable wettability have a great potential application in bidirectional oil-water separation. In this work, a simple, low-cost and environmentally friendly strategy is developed to construct a pH-responsive melamine sponge (MS) with reversible wettability via polydopamine (PDA) modification followed by grafting long-chain alkanes with carboxyl (–COOH) and methyl (–CH3) groups. The as-modified sponge exhibits unique pH-responsiveness, that is, the water contact angle (WCA) is measured to be 144.9° under acidic and neutral environments, while the wettability is radically changed from hydrophobic to hydrophilic under alkaline conditions. Moreover, in alkaline environment, the pH-responsive sponge can rapidly release the absorbed oil, demonstrating a controllable desorption performance. Also, the prepared sponge is utilized to accomplish controllable separation of various oil/water mixtures, as well as to effectively separate oil-in-water emulsions. Furthermore, after 50 cycles, the oil-water separation efficiency was still higher than 92 %. This smart wettability sponge has an extensive application prospect in controlled oil-water separation and on-demand oil-spill remediation.