If I am working in Dubai and want to switch employer, is it necessary to exit from the country?

Not in all cases. There is a new policy in UAE where updating of visa status can be done online. This would require, however, that you comply with the requirements in switching employers such as getting a No Objection Certification or that you finish your contract and you are able to find a new employer or sponsor.