Allocation of hydrocarbons to their original production sources, also known as hydrocarbon accounting, is a key factor for the distribution of costs, revenues and taxes between interested parties in field development and production of oil and gas. When developing an allocation system, the allocation uncertainties in the system should be understood and accepted by all involved parties. Furthermore, the implemented allocation system should be cost efficient and practical to operate. One of the pivotal design questions for such an allocation system is the choice of measurement uncertainty of the individual metering stations comprising the system. In this paper, we device a framework for allocation system modelling that allows for an algorithmic solution to the problem of optimizing the allocation system setup, i.e., choosing the right meter with the right uncertainty at the right place. This includes balancing the risk associated with misallocation due to measurement uncertainty against the cost of realizing the system. The presented framework makes use of a combination of optimization and ISO Guide to the Expression of Uncertainty in Measurement (ISO GUM) compliant Monte Carlo simulations. We illustrate the usefulness of our framework by applying it to example allocation systems with different allocation principles and production rates. We review the obtained results and provide a discussion of strengths and current limitations of the proposed approach.