Main railway stations are Porta Fiorentina and Porta Romana. To arrive at Porta Romana, you can take a Regional Train or a Regional Faster Train (hosted by Ferrovie dello Stato Italiano , the Italian Train Government Service) from Roma Termini, Roma Tiburtina or Roma Ostiense. This trip could be take 1½-2 hours. In alternative, you can take an extra-urban train (this service is hosted by ATAC, the Roman Transport Government Service) from Roma Saxa Rubra or Roma Ostiense.
From Rome take the ring road of GRA to the Cassia bis exit and follow this road to Viterbo. An alternative, but longer route, is to take the A1 motorway (from Rome follow the signs towards Firenze, and exit at Orte. Then take the S204 towards Viterbo (about €3 tolls from Rome). It's not really comfortable to drive inside the historical centre, as all the streets are quite narrow and “one way”. Better to park your car out of the town walls.
From the bus station of Roma Saxa Rubra take a COTRAL (the government company for extra-city transport in Lazio) Bus to Viterbo and leave at Porta Romana bus stop (at five minutes by foot from historical centre) or at Riello (the bus station of Viterbo). The trip takes about 1½ hours. The price are: ordinary ticket from Roma Saxa Rubra to Viterbo €4; ordinary ticket on board from Roma Saxa Rubra to Viterbo €7).