Whether using pre-built roof trusses or building more traditional rafters, roof joists are typically placed 24 inches apart. The other most commonly found spacing is 16-inch centers. Sometimes, builders decide to use a distance between these two points. Usually this would mean that the joists are placed on 19.2-inch centers. Other exceptions also exist when builders are creating specialized designs that don't fall under standard building specifications, or when making accommodations at the end of a building when the total distance of the roof can't be evenly divided into identical spacing between every set of joists.
If you buy pre-built trusses instead of using the older style rafter and joist construction, your trusses should specify whether they are rated to be installed on 16- or 24-inch centers. The strength and support provided in the truss design plays a part in how far apart they need to be placed. Stronger trusses can afford to be farther apart because they still provide enough strength to support the combined weight of the roof deck, roofing material and any potential snow load.
If you choose to use heavy roofing material or if you live in an area where large snow loads are a possibility, then you might need to place your roof joists closer together. The increased load might put too much strain on the decking of the roof if it has to span 24 instead of 16 inches. Local building codes may dictate narrower spacing because of snow loads, and the manufacturers of roofing products should have criteria that outline the required joist support underneath their products. If you're building your own rafters and joists out of lumber rather than using pre-fabricated trusses, building codes also dictate what spacing you should use based on the type of lumber and the span covered by the joists.
Other factors affect the strength of a roof more than the on-center spacing of the roof joists. The span that a joist has to reach across is important in determining the overall strength of a roof. If a ceiling joist needs to reach across a significant distance, you might need to place them closer together to increase the strength of the roof in compensation for the weakness of the span. This is also why specialized trusses are used to reach over longer spans. Builders might place joists as close to each other as 12 inches on center if longer spans need to be covered.