There are two places I normally place my sentry guns: on long sight lines and in corners. When you place one on a long sight line (usually a long hallway or open gap between buildings), you have the potential to rack up kills because it may take opponents too long to zero in on the sentry gun the first couple times. Also, the sentry guns seem to have a significant range, so it will shoot them even if it only sees them briefly. However, the downside to this is that it is usually easy to sneak up on from behind.
Example: place the sentry gun on top of the rock platform on 'Jungle'. It can usually depress far enough to cover a large area of the jungle floor. Also, it is hard to flash in that position. However, a skilled player with a rocket can take it out fairly easily and it is extremely easy to sneak up on from the back.
Placing a sentry gun in corners allows the sentry gun to last longer, but often at the expense of slower kills. A lower coverage area means the sentry gun may not see as many people.
Example: place the sentry gun on 'Hanoi' on the raised grass area near the 'B' flag is on Domination. It will be harder to sneak up on, but its reduced sight line may mean fewer kills.
The heat maps idea as said above is great, and once you play for awhile, you will likely instinctively know the heavily traveled areas. Ideally, you could place the sentry gun in a corner with a long sight line down a choke point. However, few such positions exist. Sentry guns are easier to use on smaller maps, like 'Nuketown' and 'Firing Range', so placement is much more important on larger maps.
Good luck and happy killing!