In this study, to optimize the foaming activity of sodium dodecyl sulfate (SDS), modified sodium dodecyl sulfate surfactants (MSDS-1 and MSDS-2) are prepared by using methanol and diethanol amine as modifiers by the Mannich reaction. The foaming properties and foam stability of the products are evaluated by the Ross–Miles method and the Waring blender method. The microstructures of the foams produced by three surfactants are compared. The effects of temperature, inorganic salt, methanol, and condensate oil on the foaming activity of SDS, MSDS-1, and MSDS-2 are studied. The results obtained show that the best foaming concentration of all three products is 0.5%. Compared with SDS, the temperature resistance, methanol resistance, salt resistance and anti-condensate oil performance of MSDS-1 and MSDS-2 are improved. Among them, the temperature resistance, salt resistance, and methanol resistance of the MSDS-1 solution are the best. The MSDS-2 solution has the best anti-condensate performance. Besides, the foam size becomes smaller, the foam wall thickens, and the foam stability is improved after modification. The overall performance of SDS as a foaming agent can be improved by the Mannich modification.