The thrust and/or propulsive efficiency of a single flapping airfoil is-maximized by using a numerical optimization method based on the steepest ascent. The flapping motion of the airfoil is described by a combined sinusoidal plunge and pitching motion. Optimization parameters are taken to be the amplitudes of the plunge and pitching motions and the phase shift between them at a fixed flapping frequency. Two-dimensional, unsteady, low-speed, laminar, and turbulent flows are computed by using a Navier-Stokes solver on moving overset grids. Computations are performed in parallel in a computer cluster. The optimization data show that high thrust values may be obtained at the expense of propulsive efficiency. For a high propulsive efficiency, the effective angle of attack of the airfoil is reduced, and large-scale vortex formations at the leading edge are prevented.