Optimal control theory is applied to obtain infrared laser pulses for selective vibrational excitation in a heteronuclear diatomic molecule. The problem of finding the optimized field is phrased as a maximization of a cost functional which depends on the laser field. A time dependent Gaussian factor is introduced in the field prior to evaluation of the cost functional for better field shape. Conjugate gradient method21,24 is used for optimization of constructed cost functional. At each instant of time, the optimal electric field is calculated and used for the subsequent quantum dynamics, within the dipole approximation. The results are obtained using both Morse potential as well as potential energy obtained using ab initio calculations.