A security officer was an officer who worked for Starfleet Security, and was, as such, part of a starship or starbase's security department, under the command of a security chief.
A security officer's duties include the protection of Starfleet and Federation assets, the prevention and investigation of crimes, and personal protection of Starfleet officers and Federation or foreign dignitaries.
In the 23rd century, it was customary for landing parties to include a number of security officers as guards.
In 2366, Captain Jean-Luc Picard received a message from the security officer of the Klingon starship IKS Bortas. (TNG: "The Defector")