That’s the meta-ethics. Not “is action A right or wrong”, but “what is the source of moral code and how do we know”?
Answers include religion, utilitarianism, intuition, local/cultural/social agreement… but that’s why it’s tough to argue that moral truths should always be equivalent to legal regulations.
In the specific example, it comes down to whether you think the moral question of sex work is “significant” enough to warrant legal restrictions.
(I’d hold that any form of abuse is both wrong and should be illegal, but voluntary activity that doesn’t harm another should be legal, regardless of whether it can be defined as morally wrong - or not!)
In a simple world, those significant things include the big ones: murder, theft, blatant fraud, etc., but perhaps not the controversial topics like personal drug use or sex work.