The diverter in a tub spout controls the flow of water from the faucet. Pulling up on the diverter's knob will cause the water to come out of the showerhead, while leaving the knob down will allow the water to flow out of the spout. If the diverter on your tub's spout is broken, obtain an exact replacement from your local hardware store. The new spout must attach to the water pipe the same way as the old one, and the diverter must be located in the same portion of the spout.
Inspect the bottom of the bathtub's spout for a set screw securing the spout to the water pipe. Use a small Allen wrench to remove the screw, being careful not to drop it down the drain.
Clamp a pipe wrench onto the spout and turn the spout counterclockwise, if you do not see a set screw. Continue turning the faucet until it comes free from the water pipe.
Slide the spout off the water pipe if you did remove a set screw, turning the spout back and forth as you pull it off.
Install a new bathtub spout in the opposite way you removed the old one. Turn on the faucet and pull up on the diverter to make sure it directs water to the showerhead.