I have been there as the grieving person (my spouse died almost 7 years ago) and as the person who has a coworker who has suffered a major loss.
There are multiple types of grief and some impact people at work more than others. Griefs where the person lives with you are often much more difficult to deal with than those of even close relatives you see less frequently. It is much more likely that a person who lost a spouse of child will be more stressed for longer at work.
It is virtually always the right thing to do to send a card or an email. If the bereavement is known in the organization, people will feel better if they receive acknowledgement of the event in some fashion. Flowers are a good gesture too, but think of the poor person stuck with taking them home from the funeral home and send them in groups from work, not one from each person.
If the obituary states a preference for a charity donation, that is usually a nicer gesture than flowers and often less costly.
The closer the person was to the bereaved, the more it is appreciated if you attend the funeral or viewing. If the funeral is local and the person who died was spouse or child, please do try to get to the funeral if you work directly with the person.
It is nice gesture if the deceased was a parent or sibling and generally not expected if the relative is further out than that. If the funeral is out of town and you know the personal email of the person, then an email that just says something about "thinking of you on this difficult day" is a kind thing that takes less than a minute to do.
On to work-specific things. First if the person is on bereavement leave and you can help get his or her work done, pitch in and help. It is hard enough to be on bereavement leave without coming back to a work nightmare. This is the single most helpful thing you can do.
The first time you see the person (or contact them informally by telephone (not a conference call) or IM if they are remote), take the time to express sympathy. Most of my remote co-workers took a minute to call me the first day I came back to work. It was most appreciated.
If the person seems to want to change the subject, let it go and don't bring it up again unless they do. If the person wants to talk, be kind and listen even if it makes you feel uncomfortable. That first week back, if you can ask them if there is anything you can do to ease their workload, it is appreciated in general. The ones who want to work to avoid concentrating on the grief will turn down your offer, but will likely still appreciate it.
Next, when my spouse died, little gestures from co-workers meant a lot. Money is likely tight when a spouse dies (I lost half my family income but not half the bills), so a restaurant gift certificate is a nice gesture. Other nice gestures I remember were a piece of high quality chocolate, cards on my desk left weeks after the funeral, co-workers who sat near me who kept other people away when I would sit there and cry, the co-workers who came and fixed my fence when it fell down in a storm, a co-worker who made sure I had something to do on my birthday, people who checked in on me periodically especially around major holidays. Grief doesn't magically end when someone comes back from bereavement leave.
If the person is struggling to get through the day (If you think they are struggling, they are), do or say something nice. Offer to handle that call with the client that everybody hates. Do anything you can at that point to help relieve some stress. If the person breaks down in tears in front of you (I cried every day at work for over a year), then a pat on the shoulder or just listening without being critical can help.
Recognize that the person will not be performing at his or her usual level. Try to cut them some slack when you can. This doesn't mean you have to let them do nothing or you have to accept bad performance. But there is a difference between a good worker working at half his usual pace temporarily and a slacker who never wants to try. Give people the benefit of the doubt when you know they are grieving. Even if you aren't the person's boss, you can do this. For instance, suppose you sent an email that needed a reply and you would normally have gotten one immediately from this person but didn't. Don't escalate the issue to his or her boss, but go to them again and gently remind them you need an answer.
But expect performance to pick up within a couple of weeks after they come back.