Given how STOs operate in-game, it makes sense to divide your anti-ship STOs and your anti-missile STOs into different groups; otherwise you'll have to give the unit different orders depending on what you need them to target, which, while not horrible, is that much more micromanagement that you're giving yourself.
STO targeting orders are given on a per-element basis, not a per-formation basis. If you have anti-ship and PD weapons in the same formation they can each target independently, so once you set them up they require no further management.
OP: The bigger issue here is that, with only 2 STO elements (totaling 3 units) per formation, giving those orders will be a lot of micromanagement to setup since you'll likely need a large number of formations to get appreciable defensive firepower. I would recommend using larger formation sizes, at least 5,000 tons if not larger, in order to reduce the micromanagement, and it is a good practice anyways.