I would not like to write here why the role of having fun at work is important (and if it is important at all) and if everyone shall do that with their teams but perhaps few will consider it a good practice and will try it once or two. I am a very big opponent of building hierarchies in projects and I believe that such team building activities help flattening organization a bit. There is also just one simple reason for that - breaking the barriers - You will know sooner that there is something wrong with the project if there are no barriers (communication barriers) between You and team. If there are no barriers and Your team is perfect than still some additional fun might be helpful in increasing ex. productivity. In worst case team will just have some fun (in worst worst case the team will not have fun at all in fact).
Building a team.The best moment to start playing at work is when you start a project and the team is being formed. Sometimes the members know each other but more often they don't (or they don't know each other good enough), or you have a couple of new people on board. Team games help the team get to know each other, be less formal. You could even think of some game that You play when new member joins Your team. Or even some fun game when someone leaves (so he propagates this idea to another team he's joining) :).
So you want to be a team member?Very simple - join the team and have fun with them :). Be a part of each game. Sometimes the game needs a moderator - ask someone to be a moderator and play with other team members. Ask the team if they know some good games and play. Have fun :). Use the team's best feature - self organizing. A very good idea could be including a product owner or some other high level managers / customers in games, because these are usually natural barriers to be broken.
When is a good time for play.The project is running for several months already. The team is a bit bored. Or not :). And you have a retrospective at each iteration end - this is a good time to have some games. Just before the retrospective. Take a few minutes to tell the rules and another couple of minutes to play it. You can also try to play some games during daily meeting. Randomly - from time to time. Or even organize such event separately, book a conference room, have some cookies and coffee. I think this should be short - 15 to 30 minutes. Otherwise your boss might not like it that much :) (like if he ever liked it).
When not to play.I am not sure if there are any circumstances under which you should stop playing. When the project goes down you definitely should try playing - and definitely invite as much people as possible. Perhaps after a game you will be able to solve the problems that the team/project have? Sometimes the company policy might be such that you should not try to have fun at work,
How about distributed teams?Of course they can not play games that require direct contact. But still they can play. You can use games offered on Skype or one of millions of sites with games for teams :). I took a part once in a very interesting game of "Chinese checkers". I enjoyed it a lot and hope we'll do it few times more :).
Few examples.Game shall have a purpose. Like this one: Make pairs of people. Let them choose who is boss and who is employee. Put all employees in a square (draw a line on the floor, or something like this). The square shall be big enough so each employee has at lease 1-2 m2 for him. And now the fun - the employee moves in directions that the boss will tell, so the could be 'one step right', 'one step forward', etc. The pair that makes the most moves wins. 2nd round allows employee to make moves without direct orders - he moves as he wants and the goal is to make as many moves as possible is same time interval. Does anyone need a boss anymore?
Or this one: You have ex. three balls - the team scores 1 point when all balls make full cycle. Full cycle is when all team members touch each ball once. One team member can hold one ball at a time. Let the team think about what they can do to make the best score and let them work for a minute or two. After the first cycle let them improve the way they were working and ask them to estimate how mmuch can they score during same time interval. And then make a third round. Retrospectives are important, aren't they?
If You need to prototype something, like UI you can buy some color paper and scissors and let the team prototype. Or use the black board. This is fun way to do some brainstorming.
There are a lot of games that You can do with the team. Here is a good place to start looking.
It's all about the brains. People get smarter when they learn and have fun at same time. People don't stress so much when they have fun and then the get relaxed. Relaxed brain is more productive and so on, and so on. I think it is worth to try to go further with fun - to take it to the meetings and have fun during retrospectives or daily meetings. If you have some budget you could also give some puzzle games to Your team, so they can relax during work (or at home) - You could try something like 'neocube', or even Rubik's cube but there are plenty of others out there.
Try it and have fun :).