In this work, we develop a model for a gravity separator, and use it together with models from literature to study the control of a subsea separation system that separates oil, gas and water from well fluids in hydrocarbon production. Our separation system contains a gravity separator, hydrocyclones and compact flotation units. The main contributions of the paper are twofold. First, we present a coalescence based dynamic gravity separator model, which is able to predict oil concentration in water outlet and water concentration in oil outlet. Second, we study optimal operation of the overall separation system with an objective of maximizing water removal. We propose a simple control structure that operates the process close to optimally, by rejecting disturbances from upstream flows and maintaining a tight control of the quality of the purified water leaving the system.