3D numerical method is presented for simulation of foam formation and dynamics in viscous flows in the presence of insoluble surfactant and under the influence of van der Waals forces. The mathematical model is based on the Stokes equations in the fluid phases, coupled with velocity and stress boundary conditions at the interfaces. A nonuniform surfactant concentration on the interfaces, governed by a convection-diffusion equation, leads to a gradient of the interfacial tension, which in turns leads to an additional tangential stress on the interfaces. The presented numerical method is a semi-implicit coupling of a boundary-integral method for the velocity in the fluid phases with a finite-volume method for the surfactant concentration on the interfaces. Additional elements of the method are: Nonsingular contour integration of the singular layer potential; Higher order approximation of the interface position; Dynamic mesh regularization.