If you really want to get all that you can out of a set of guitar strings you could play them until one of them breaks. You could replace the one that breaks and then keep using them but at this point you might as well change the entire set. Basically the strings will begin to loose their bright tone after they have been played for several days or even hours if you do a lot of heavy, sweaty playing. Under normal playing though this is really not so noticeable on electric guitars and a set should last for weeks or months even, again depending on how often you play.
On acoustics however, I have always been somewhat of a stickler for keeping the strings fresh. The reason is that the acoustic guitar is capable of producing such a natural, woody and raw sound that I actually expect it so sing and ring-out crystal clear so once they start loosing their crisp sound I will change them, especially when recording.
Under conditions where your hands sweat a lot, or in really humid conditions, the guitar strings can actually begin to rust a bit. I have seen some brutally rusty strings before and they are definitely not playable when they get to that condition. One suggestion to actually help prolong the life of a set of strings is to simply wipe them down with a soft cloth after each time that you play your guitar. This will help prevent any rust issues and it will also help keep any crud from building up on them.
There are also products which you can wipe on or spray on which will also work towards keeping the strings clean, bright and longer lasting. For those players who do not really play their guitar very often, if you keep the stings wiped down than a set could last for many months and still sound good whether on an acoustic or an electric.