Great question! A lot of this depends on the particular situation. If, for instance, you're a junior on a job and a senior worker (and friend) suggests that you go out for a Pepsi together, if he offers to pay, an "Oh, thanks!" is all that's necessary.
On the other hand, if this among friends whom you frequently spend time with, I personally just try to take on my fair share of it. In other words, if we go out, say, once a week with four of us, I'd just take the tab once every 3-4 weeks.
Furthermore, it depends on the value you put on the given relationship(s). If these are good friends, for myself, I'd offer to take it just a bit more often than what would be my "fair share."
As to telling if someone else is planning on picking it up - it really depends on the situation again. If you know the friends well, it's not too bad, but if they're people you don't really know all that well, it could be a bit more tricky.
To a large extent, it will depend on your particular area and circle of friends. I'd recommend taking the trouble to observe who usually suggests going out and who usually picks up the tab. Is there some observable pattern? Is it usually the person who proposes it that ends up paying? To a large extent, you can avoid doing something embarrassing simply by observing and doing like other people do.*
*This is a general rule that does not apply in all situations. Use your good sense. :)