There is no one correct pipe length for a tub spout. Because spouts are different sizes and the plumbing behind the wall is installed at different depths, it's necessary to measure and purchase or make a pipe when installing a new spout.
Measure the length of your tub spout from the back edge of the spout to the front where the threads start on the inside of the spout. Then measure the distance from the surface of the wall to the back of the threaded elbow inside the wall. Total the two and add 1/4 inch. The result is the overall length of the pipe you need.
Video of the Day
The length of pipe you need to attach your tub spout will often be very close to a piece of standard-size galvanized pipe called a nipple. If not, many hardware stores can cut and thread a piece of pipe for you.
Make Your Own
If you know how to work with copper tubing, you can put together your own pipe. You'll need two male adapter connectors and a length of copper tubing. Remember that it's the overall length you need, so be sure to factor in the length of the connectors when cutting the tubing or your pipe will be too long.