In the exploration, development, and production of hydrocarbons, a sovereign state faces conflicting challenges: maximizing its welfare while maintaining an attractive investment environment for developers. The terms and conditions of a production sharing contract (PSC) between the government and international oil companies (IOC) are usually finalized prior to the commencement of operations and with partial knowledge of the reserve level. In addition, hydrocarbons have several potential uses. This paper formulates an optimization model that assists the government in these challenges. Given an initial estimated reserve volume and hydrocarbon price, the model determines values for both the PSC's key parameters and the allocation of the government share into different uses to generate the maximum benefit to the state while providing an acceptable rate of return for the IOC. The model is applied to Lebanon. We find that an optimal PSC for Lebanon involves no royalty for all reasonable values of potential reserves, and a high cost recovery and profit share for low reserve volumes. In addition, sensitivity analysis indicates that the preferred export mode is via the Arab pipeline, due to the low level of the current gas price and high cost of the alternative liquefied natural gas export mode.