This depends on the type of railway sleepers you have. Reclaimed railway sleepers are usually made from high grade Oak or other dense exotic hardwood, and have usually been treated with Creasote, Tar or some other industrial grade preservative. Reclaimed railway sleepers are likely to last for decades above ground if left untreated. This said, applying a wood preservative or wood oil will help to protect the timber for longer.
Reproduction railway sleepers are usually made from Oak or Pine. They can be bought untreated and pre-preserved. It is worth checking this with the supplier if you are unsure. A new, preserved sleeper will have a greenish brown tinge much like a new fence panel.
New reproduction sleepers will benefit from the use of a wood preserver and an exterior wood oil such as Manns Premier UV Decking Oil. Where possible, treat all sides and cut ends prior to installation.