In this work, we investigate the optimal gait for fish-like swimming using a 2D oscillating plate that undergoes pitching and heaving motion. Specifically, we develop and use an efficient adjoint-based optimization algorithm to find the periodic gait that maximizes the propulsive efficiency. The optimal gait obtained from the optimization algorithm is very close to a pure sinusoidal gait with the heaving leading the pitching by approximately 90◦ . A sensitivity analysis of the efficiency with respect to the change of the flowfiled is also carried out. The sensitivity analysis shows that the efficiency is most sensitive to the perturbation in the flowfield upstream of the plate and the flowfield near the plate.