We consider an optimal control problem with differential and integral constraints. The initial condition in the control system of ordinary differential equations has a nonlocal form; it is defined by the solution of the system. We develop and substantiate an algorithm for finding an optimal control maximizing the profit. The algorithm allows one to reduce the solution of the original problem to the solution of simpler optimal control problems related through one of the parameters of the model. We show that one can find a parameter value that determines the solution of the original problem, and we explain how to do this. The approach proposed allows one to efficiently solve optimization problems arising in models of control of structured populations interacting at stationary states.