Australian military personnel should carefully consider wearing their uniforms in public, the Defence Department says, after an officer reported being attacked in Sydney.

The 41-year old Australian Defence Force (ADF) officer said he was threatened and assaulted by two males in Sydney's north-west and suffered minor bruising, NSW police said.

The man called police to report the incident early on Thursday and later spoke to officers at the Kings Cross station.

The two alleged assailants have been described as being of Middle Eastern appearance, police said.

The Hills Local Area Command was investigating.

While the Defence Department has said it would not discuss details about any threats against ADF personnel or their families, a spokesperson said members had been advised to exercise their judgement about wearing a uniform in public.

"ADF members have been advised to consider where they are going, to be aware of their surroundings, and to exercise commonsense and judgement when considering where and when to wear uniform in public," the spokesperson said.

The incident comes amid concerns about the safety of police officers following an attack in Melbourne on Tuesday which saw two officers injured and their apparent attacker shot dead.