The article discusses the optimal management of the distribution of net profit of oil and gas enterprises in order to minimize its risks. The constructed utility function acts as a criterion of optimality. Management parameters are fractions of net profit aimed at achieving the final predicted value of the studied variables. To solve this problem, a mathematical apparatus was used, based on the theory of the Pontryagin maximum principle. As a numerical experiment, some options are proposed for optimal management of the distribution of net profit of the National Joint Stock Company Naftogaz of Ukraine for the period 2018-2022. Numerical results are given taking into account the discounting of financial flows. The proposed algorithm allows to obtain the optimal distribution of net profit within one oil and gas enterprise, which includes structural units, as well as on the scale of a group of enterprises united by one governing body that distributes financial resources for risk management. Keywords-profit, oil and gas enterprises, optimal management, utility function, risk I.