An optimal oxygen concentration trajectory in an isothermal OCM plug flow reactor for maximizing C2 production was determined by the algorithm of piecewise linear continuous optimal control by iterative dynamic programming (PLCOCIDP). The best performance of the reactor was obtained at 1,085 K with a yield of 53.9%; while, at its maximum value, it only reached 12.7% in case of having no control on the oxygen concentration along the reactor. Also, the effects of different parameters such as reactor temperature, contact time, and dilution ratio (N2 /CH4) on the yield of C2 hydrocarbons and corresponding optimal profile of oxygen concentration were studied. The results showed an improvement of C2 production at higher contact times or lower dilution ratios. Furthermore, in the process of oxidative coupling of methane, controlling oxygen concentration along the reactor was more important than controlling the reactor temperature. In addition, oxygen feeding strategy had almost no effect on the optimum temperature of the reactor. Finally, using the optimal oxygen strategy along the reactor has more effect on ethylene selectivity compared to ethane.