An autofocusing method based on cosine similarity in dual-wavelength digital holographic microscopy is proposed. In our experiments, red and green lasers are employed for illumination and the generated holograms are recorded by a color camera. During the refocusing process, the reconstructed optical field near the focus plane contains more regular features than the one on the defocus plane. Moreover, due to the wavelength dependency of the diffraction process, the further away from the focus plane, the greater the difference in the reconstructed optical fields from the two wavelengths. Therefore, the focus plane can be determined by finding the maximum value of the cosine similarity between the amplitude vectors from the reconstructed optical fields of the two wavelengths. Simulation and experimental results demonstrate the effectiveness of the proposed method in off-axis dual-wavelength digital holographic microscopy for shape measurement.