In this work, we have solved two practices problems in agriculture by modeling in problems of optimal control. An emphasis is placed on nonlinear control optimal problems, since the output of the resulting models are nonlinear. It provided a way to choose defaults for the weight between minimizing pollution caused by an improper addition of fertilizers and insecticides and maximize cereal production. The first problem is to maximize cereal production taking into account the detrimental effects of pollution generated by adding abusive fertilizers. Subsequently, the second problem, we refined the first problem by introducing the constraint of the presence of locusts. For digital applications, were used actual data from the Algerian Ministry of Agriculture and Data from the National Institute of Plant Protection (INPV).