In practical terms in the US, nearly any time someone uses that phrase, they are an attorney. From context, OP is probably neither a prosecutor nor a criminal defense attorney, because they would likely mention that given its relevance.
Technically though, officer of the court is a pretty broad term that includes judges, magistrates, medical examiners and coroners, process servers, interpreters, and even bail bondsman. Anyone who plays a role in the functioning of the court and has duties to ensure justice is carried out. But really in practice you never hear anyone except lawyers refer to themselves as such.
It's usually a phrase we use to indicate that messing with us means messing with the judicial system, which tends to invite harsh punishment from judges, who are after all themselves attorneys.