It all depends on what your top rpm is. (Higher rpm needs shorter length). The distance from piston to 60% of the baffle cone (2nd one) needs to jive with your top rpm, exhaust port open duration, and exhaust temperature (higher with high compression). Instead of becoming a math wiz at this its best to just experiment with header pipe lengths.
For my bike which revs to 7500 rpm I needed 34 inches.
Unfortunately most pipes have too steep a baffle angle to be of much use to anything but pipey pocketbikes. (steep angles give narrow powerbands). I just made my own pipe and with it I lost a little low end, top end power was the same even though it was made to have as broad a powerband as possible. After changing the jetting to be a bit richer I got the best low rpm power ever but lost some speed on the top end. Seems like I have to chose one or the other.