How to set custom DNS entry for a particular wifi connection
What you want to do is Add a Network Location for work.
You can then easily switch between them using the Location submenu of the menu.
If you really wanted, you could set up a script to switch locations based on network, but really, how lazy do you want to be? ;)
You can use Control Plane to switch context automatically depending on nearby WiFi networks, location, … or tons of other conditions.