Basic understanding of numerical modelling for the effects of CO2 foaming on heavy oil production behaviour using the huff‐and‐puff process is relevant for CO2‐EOR performance. The numerical model was constructed based on laboratory measurements: CO2 solubility, foam swelling, and apparent viscosity. The model for unsaturated solubility in porous media, such as sandstone cores and oil reservoirs, was proposed by defining CO2 solubility in heavy oil for generating foamy oil. The foaming process was modelled with four kinds of foamy oils at discrete depressurizations below each equilibrium pressure. A numerical model of apparent foam viscosity with discrete depressurization was set up based on experimental measurements as a function of pressures and temperatures of 0.1–10 MPa and 20–50 °C. The matching between the numerical simulations of heavy oil drainage and experimental measurements of foaming in Berea sandstone cores (Psat = 10 MPa at 50 °C) shows 31 % oil recovery after depressurization to atmospheric pressure. The numerical simulation results of heavy oil production at field‐scale showed that CO2 gas production quickly increases after depressurization and then the foamy oil production increases following the peak gas production rate. In the first cycle of the huff‐and‐puff process, the maximum oil production rate ranged from 4–68 m3/day. From the sensitivity study it can be concluded that the initial oil saturation and the CO2 dissolution zone as compared with reservoir size play a main function in heavy oil production by CO2 gas foaming in the huff‐and‐puff process.