To achieve the dual objectives of utilizing agricultural waste and efficiently removing sulfamethoxazole (SMX) from water, this study prepared biochar from corn straw at 700 °C. The biochar was subsequently activated via KOH and H₃PO₄ treatments to produce two types of modified biomass-activated carbon: KOH-C and H₃PO₄-C. Both activated carbons exhibited similar surface functional groups. The adsorption kinetics of SMX were better described by the pseudo-second-order model, while both the Langmuir and Freundlich models provided good fits to the adsorption isotherm data. Characterized by a larger specific surface area and more developed pore structure, KOH-C demonstrated a higher adsorption capacity for SMX than H₃PO₄-C. Therefore, KOH-C was selected for further investigation. A Box-Behnken design combined within response surface methodology was then employed to analyze the factors influencing SMX removal. The results showed that the interactive effects of pH–dosage and pH–temperature were significant (P < 0.05). The main effects of temperature and dosage, along with the quadratic term of dosage, were highly significant (P < 0.01). Lower pH, higher temperature, and larger dosage favored SMX removal. Under the theoretically predicted optimal conditions (pH = 4, temperature = 35 °C, and dosage = 198.4 mg, equivalent to 0.992 g/L), the removal rate of SMX reached 99.9%.