The experts, and more importantly those who are grieving, say that it doesn't matter that you don't know what to say. You don't have to say anything - just be there. And listen.
When you're told of a death, what you do depends on the closeness of your relationship not only with the one who died, but with the surviving family. If you're close, your instincts will tell you what to do. This of course means a phone call to express your sorrow and offer your assistance. Don't hesitate to ask what you can do. You may get an answer or it may be too soon. In that case, something may come to you in a few hours or the next day that becomes an obvious thing that you can do. It may be taking the kids for a few hours, sitting with an older relative, preparing a meal, answering the phone for a while or making calls to other friends. Even helping to straighten up their home, knowing that they will be having lots of people around, can be a welcome offer.
One thing most people would help with if they knew, is giving something to help pay for the final expenses. Many times people assume that the person had life insurance either on their own or through an employer, or that there was some other provision for this, but there isn't. Many people struggle to pay and people don't realize there's a need. Many funeral directors discount their services or even donate some of them to make things easier for people with financial limitations but there are other items with less flexibility - cemeteries are usually less likely to donate services but some do have graves that they will discount and they'll charge less to dig the graves but this usually has to be paid upfront. Newspapers frequently require payment before an obituary or notice is printed and florists usually require some form of payment at the time flowers are ordered.
Although there is assistance available from the Department of Social Service (welfare), their guidelines are stringent and unfortunately many people are usually not eligible.
Something that most people don't do
Most people will send flowers, make a contribution to a charity, or give a mass card. This is fine at the time, but it will mean a lot if you do something after the fact. Almost every spouse (or parent, depending on the age of the person who died) comments on how difficult it is after the relatives and friends leave to go back home, sometimes to a different city, after the funeral. Send flowers, a card, or even a mass card on the person's first birthday after their death, on the day of a wedding anniversary, or even just a few weeks after the funeral. Don't forget to acknowledge their feelings around the holidays, too. It will be sad and you may think you don't want to say something and make them cry but even though it may bring tears, it will mean a lot to them. They still want to hear people say the name of the person they loved. Don't hesitate to do it and share a good memory with the person.
Sometimes, for no occasion other than that they may be having a hard time, give them a call and ask them out for lunch or dinner or to a movie or concert. Even a day of pampering would be a wonderful thing - just be sure you offer what that person considers to be pampering, which could be a day at the spa, an afternoon at a batting cage, or just a cup of coffee or an ice cream treat.