Optimal segregation of proteins: phase transitions and symmetry breaking