Nakhon Pathom city is just a little over 50 kilometers from Bangkok, so getting there is relatively easy. Your basic options are bus or train.
Buses leave Bangkok's southern bus terminal every 10 to 15 minutes, and take about one hour depending on traffic. The fare is around 40 Baht (1.07 USD). The drawback to taking the bus is that the southern bus is located on the western side of Bangkok, well away from the main tourist areas, as well as the trains.
Trains are a slightly easier option. Trains leave from both the main Hua Lamphong station as well as the Thonburi Station. Unless you're staying on the river, the Hua Lamphong station is easier to get to. All trains on the Southern Line from Hua Lamphong stop in Nakhon Pathom. There are trains more or less hourly. There are only two or three trains a day from Thonburi, which have Kanchanaburi as their final destination. The fare to/from Nakhon Pathom is around 14 Baht (0.37 USD). Check Seat 61 or the State Railway of Thailand sites for current schedule.