Red is the command track. That is what you wear if you are in command or you don't hold a position with any of the science or engineering teams, or you aren't on security.
Blue is medical and sciences. The doctors and other scientists wear blue.
Gold is security and engineering. All the engineers and everyone assigned to security wear gold.
Security and engineering are generally grouped together as 'operations', presumably ship-related duties like engineering and security (as you've mentioned).
Medical and science are also usually grouped together as simply 'sciences', medicine, astronomy, geology, all that stuff under the one umbrella.