We analyze an optomechanical system that can be used to efficiently transfer a quantum state between an optical cavity and a distant mechanical oscillator coupled to a second optical cavity. We show that for a moderate mechanical Q-factor it is possible to achieve a transfer efficiency of $99.4%$ by using adjustable cavity damping rates and destructive interference. We also show that the quantum mechanical oscillator can be used as a quantum memory device with an efficiency of $96%$ employing a pulsed optomechanical coupling. Although the mechanical dissipation slightly decreases the efficiency, its effect can be significantly reduced by designing a high-Q mechanical oscillator.