The gas injection is a widely used technique for improving oil recovery; however, in reservoirs with heterogeneous characteristics, the injection of gas in the form of foam is more promising. Due to the heterogeneous nature of oil reservoirs, we compared the foam flow performance at the tertiary mode with that of gas injection using an anionic surfactant AOS and a cationic surfactant CTAB. Glass bead packed models were used with different patterns of wettability heterogeneity including oil-wet, water-wet, stripe, layer, and quadrant. While gas injection in heterogeneous models produced only 10–15% of the waterflood residual oil, foam injection could control the gas mobility and recover almost 30–50% of the residual oil. The most stable foam was formed in the water-wet porous medium whereas the lowest stable foam was visually observed in the oil-wet porous medium due to the presence of more residual oil. However, the synergistic effect of wettability alteration and piston-wise displacement of the foam front improved oil recovery even in the oil-wet medium compared to the gas injection scenarios. Among all heterogeneous models, the highest oil recovery was achieved in the layer model and its oil recovery profile was compatible with that of the water-wet homogeneous model. Conversely, we found that positioning an oil-wet layer strongly declined foam flow performance as was observed in both layer and quadrant models. Compared to the AOS foam, the CTAB foam was more stable and efficient in recovering waterflood residual oil in the models under study.