This is a complicated topic with no general answer. If you get a set of ACA maps and follow an ACA route, the maps will tell you where you can camp (although you may also be able to camp elsewhere). The best general approach is first look for signs that might indicate "no trespassing" or "no camping." If you find no signs, ask permission. But who to ask is tricky too. If there is a nearby house, that's a good place to ask. If you can find the local police or sheriff, that usually works. If you cannot find anybody to ask, you can just take the risk and set up your tent in as inconspicuous a place as possible. The worst that would probably happen would be to get asked to leave in the middle of the night.
If you camp in an established campground, some may be free, or there may be a small charge (perhaps around $6) or there may be a large charge (up to $30). It's usually (but not always) cheaper to look for public campgrounds (run by the state or federal government) than private campgrounds. It's always a good idea to ask if there is a cheaper rate for cyclists. You might also consider asking someone already in the campground if you can share their site.
Sometimes cities let cyclists pitch in their city parks overnight (usually for free), but it's usually best to ask the local police. In rural areas, look for a spot where you can be out of sight from any road or building.