For scattering problems of time-harmonic waves, the boundary integral equation (BIE) methods are highly competitive, since they are formulated on lower-dimension boundaries or interfaces, and can automatically satisfy outgoing radiation conditions. For scattering problems in a layered medium, standard BIE methods based on the Greens function of the background medium must evaluate the expensive Sommefeld integrals. Alternative BIE methods based on the free-space Greens function give rise to integral equations on unbounded interfaces which are not easy to truncate, since the wave fields on these interfaces decay very slowly. We develop a BIE method based on the perfectly matched layer (PML) technique. The PMLs are widely used to suppress outgoing waves in numerical methods that directly discretize the physical space. Our PML-based BIE method uses the Greens function of the PML-transformed free space to define the boundary integral operators. The method is efficient, since the Greens function of the PML-transformed free space is easy to evaluate and the PMLs are very effective in truncating the unbounded interfaces. Numerical examples are presented to validate our method and demonstrate its accuracy.