But your right to act on that belief is constrained by laws and by employment policies. Believing interracial marriages are wrong doesn't give you the right to beat up the groom. And it doesn't give you the right to deny equal protection under the law to interracial couples.
Which means that, if you want to be a Justice of the Peace, you have to abide by the law that requires you to do your duty without prejudice. If that bugs you so much, you need to find another line of work or a way to be a Justice of the Peace who doesn't perform marriages. (if there is such a thing...)
Same thing goes for pharmacists who don't want to dispense some kinds of medicines, and teachers who don't agree with some part of the curriculum, not to mention engineers who hate certain kinds of bridges or ministers who don't like to work Sundays. Doing your job is...a condition of employment! Pharmacists who don't want to handle birth control pills are free to work in the pharmacy of home for the elderly. Teachers who don't believe in Evolution are welcome to teach English or First Grade or Special Ed to severely handcapped children or wherever else they can find that this issue won't come up. Nurses who don't want to perform abortions can find thousands of jobs where that duty will never be asked of them. Even ministers who don't want to work on Sundays can, with dilligence, creativity find paying employment.