In this study, bagasse cellulose-based porous foams were developed using bleached sugarcane bagasse pulp as the main raw material. The intention was to achieve controlled oil/water separation using low-cost and environmentally acceptable raw materials to solve the current problem of oily wastewater treatment. Bagasse cellulose-based foams with 3D structure and good mechanical properties were produced via freeze-drying. A pH-responsive copolymer was synthesized by free radical polymerization to modify the foam with pH-responsive wettability. Results showed that bagasse cellulose-based foams with an adsorption capacity of up to 48.77 g/g, and their pH-responsive properties could easily achieve the wettability transition between super-oleophilic (oil contact angle is 0°) and super-oleophobic (oil contact angle is 157.3°). The changes in foam wettability were realized by the conformational transition of pH-responsive copolymers under different pH values. Ultimately, the pH-responsive switchable wettability of the foam was still able to reach 80% adsorption capacity after five cycles, demonstrating excellent stability and recyclability.