Quantum state transfer in optical microcavities plays an important role in quantum information processing, and is essential in many optical devices, such as optical frequency converter and diode. Existing schemes are effective and realized by tuning the coupling strengths between modes. However, such approaches are severely restricted due to the small amount of strength that can be tuned and the difficulty to perform the tuning in some situations, such as on-chip microcavity system. Here, we propose a novel approach that realizes the state transfer between different modes in optical microcavities by tuning the frequency of an intermediate mode. We showed that for typical functions of frequency-tuning, such as linear and periodic functions, the state transfer can be realized successfully with different features. To optimize the process, we use gradient descent technique to find an optimal tuning function for the fast and perfect state transfer. We also showed that our approach has significant nonreciprocity with appropriate tuning variables, where one can unidirectionally transfer a state from one mode to another, but the inverse direction transfer is forbidden. This work provides an effective method for controlling the multimode interactions in on-chip optical microcavities via simple operations and it has practical applications in all-optical devices.