Officially, it is the job of the Supreme Court and lesser courts to rule on the constitutionality of laws. Soldiers are expected to know what constitutes an unlawful order, which includes things like torture and treatment of prisoners. That being said, a soldier better be darn sure that s/he knows what they are doing when they resist an order. I think that part of swearing in for the military and many elected officials include supporting the Constitution.
You get into trouble when the local sheriff says that he believes that it is unconstitutional for black people to vote, or for people to wear pro-whatever t-shirts to the anti-whatever political rally. It gets tricky when the local sheriff realizes that people as hateful as Westboro Baptist Church has the same rights for assembly as do any other group. It also gets tricky when multiple jurisdictions have different ideas of what is constitutional. In the recent Affordable Care Act/ObamaCare court cases, different lower courts ruled various parts of the law both constitutional and un-constitutional. The final say comes from the Supreme Court. Once they have ruled, only another challenge can change the law.
There are entire legal specialties called "contitutional law".
Just remember you can be charged and imprisoned for following/enforcing an order/law that is found to be unlawful.
"I was just following orders" is not a defense. So everyone has to decide if what they do is lawful or not.
So the Sheriff can use his judgment enforcing any order/law.