Depends on the state. You need to take it if you are moving in a certain time frame (like within two years of graduating dental school). However, most states let you get licensure by credentials (i.e. if you have your license in another state and are in good standing). You have to be careful with licensure by credential because some states are very specific. For example: some states allow you to get your license from portfolio... Now you have your license and you've worked there for years... If you want to move to another state by licensure they may say, "sure, you can get your license here but NOT if you get licensure by portfolio originally."
There are lots of ways to get licensure; however, if you are looking at all of your options and the only one that makes sense for your situation is having taken a test (WREB or NERB) then you may have to take a test if you have not already. For example, if you took the WREB and the state only accepts NERB then you would have to take the NERB.
If you took the WREB prior to 2018 you didn't get to do the new prosth section, some states make you take the prosth section. In my case, I had to fly out to another state, take just the prosth section, pass it, and then I was considered for licensure in the state I was moving to.
Here is an ADA source:
In the end though, once you have worked and are in good standing for a few years you pretty much can always get licensure by credential and move state to state with few exceptions. Canada is the obvious wrench here... But you wont have to keep taking the NERB over and over again for sure.