There are different ways to go to Qom from Tehran which is 135 km. it will take one hour and thirty minutes to get to this city of one million three hundred population. It is located right on the route to Kashan so it is a good idea to add it to your itinerary and you would not regret it.
If you are at the Imam Khomeini airport, you can get an airport taxi to Qom which is even closer, like an hour(95 km), but when you are in Tehran, the best way is to take the subway to the south Bus Terminal and get a taxi or a bus to Qom. the prices are quite cheap like 30 to 50 thousand Toman which is almost 2 US dollars.
Remember that if you are on a bus, you need to get off the bus at Haftado Dotan Square. It is the entrance of Qom and you can also find plenty of taxis to go to the city center.