Optical forces on a Rayleigh particle near the surface of a dielectric slab waveguide are considered. A light wave of the lowest-order mode is used to excite the particle. The transverse and longitudinal forces acting on the particle are studied. The particle is always trapped near the surface of the slab, where the electric field intensity is high. The particle can be pushed away from or pulled toward the light source along the surface of the slab by tuning the frequency around a switching frequency. This phenomenon switches between scattering and gradient forces near the switching frequency of the dielectric slab waveguide.