The track class and speed for North American railroads are governed by regulations from the Federal Railroad Administration. Better quality of track permits greater operational speeds and lower transportation cost but also requiring greater maintenance expenditure. In this study, we considered this trade-off between maintenance and transportation costs, and developed an optimization framework determining the optimal assignment for track class based upon the characteristics of the track, traffic demand, and maintenance budget. This tool can help railroads maintain tracks at their most appropriate level so as to provide reliable and cost-effective services.