The viscous effects on transonic flow past an airfoil that contains a shallow cavity beneath a porous surface are studied numerically. The porous region occupies a small portion of the total airfoil surface and is located near the shock. Both an interactive boundary-layer (IBL) algorithm and a thin-layer Navier-Stokes (TLNS) algorithm have been modified for use in studying the outer flow, whereas a stream-function formulation has been used to model the inner flow in the small cavity. The coupling procedure at the porous surface is based on Darcy’s law and on the assumption of a constant total pressure in the cavity. In addition, a modified Baldwin-Lomax turbulence model is used to consider the transpired turbulent bounday layer in the TLNS approach, and the Cebeci-Smith turbulence model is used in the IBL approach. According to the present analysis, a porous surface can reduce the wave drag appreciably, but it can also increase viscous losses. As has been observed experimentally in nonlifting airfoils, the numerical results indicate that the total drag may be reduced at higher Mach numbers and increased at lower Mach numbers. Furthermore, the streamline patterns of passive-shock and boundarylayer interaction are revealed in this study.