Fractured reservoirs are an important source of oil and gas energy. After depletion of production, the production capacity of this reservoir decreases rapidly. Effective profile control is needed to improve the sweep efficiency and reservoir heterogeneity. Foam can solve such problems, but its profile control mechanism is not fully understood. Based on this, this paper uses the level set method to study the microscale control mechanism of foam in fractured media. The results show that artificial fractures and high-permeability microfractures are tighter than natural fractures, the Jamin effect of foam is stronger, and the secondary foaming ability is better. Therefore, the plugging ability of foam to natural fractures is far less than that of foam to artificial fractures and highpermeability microfractures. The larger the fracture opening, the larger the foam volume and the smaller the flow rate. As the opening ratio increases gradually, the generated foam flows more to the natural fractures with a large opening, and the effect of foam blocking large fractures becomes worse. The diversion rate curves of different opening ratios show that the foam has a good profile control effect when the opening ratios are 4:1 and 2:1, and even the diversion rate overturns, while the profile control diversion effect is poor when the opening ratio is 10:1, so it cannot play an effective role in profile control. The foam shows the profile control process of preferentially plugging the high-permeability area and allowing more subsequent fluids to enter the low-permeability area. The research reveals the profile control mechanism of foam on fractured reservoirs from the micro level, which is the supplement and verification of relevant macro research and provides a theoretical basis for the efficient development of fractured reservoirs.