This research presents a mathematical model for the optimal allocation of oil and gas to different sectors in Iran using operations research techniques. Sectors are residential, commercial, transportation, industries, agriculture, exports, injection to oil reservoirs and power plants as a secondary energy producer. Optimal allocation of energy resources to end-users from 2011 to 2021 has been done using a linear programming model aiming to reduce greenhouse gases. Actual data of Iran from 1967 to 2008 are used to forecast the energy demand of different sectors and to illustrate capability of the approach in this regard. The results provide scientific basic for the optimal allocation of energy resources in Iran.