It depends how close you are, but "I'm sorry for your loss", is appropriate, as is "I'll be here if you need me".
Then, if it is not a close friend, back off a bit as this is a time when people are overwhelmed with well-wishers. The first two weeks are hectic and you really don't have time to deal with all the people trying to make you feel better, so it is actually respectful to let the person know that you will be around if you need them, but that you're going to give them their space.
After two weeks, things will slow down and that is when it is appropriate to ask if you can help, if they need anything, and to just check in with them.
Questions like "How are you holding up?" or "Do you need anything?" are appropriate at this time.
The thing about grief is that it takes a while to hit. The time around the death is actually the easiest. You go on auto-pilot and you're in shock. It doesn't sink in right away.
It's the weeks afterward, when everyone has stopped dropping in to express their regrets, after everyone has said "If you need anything...." To be a good friend, step in a few weeks later and lend your support then. That is how you can really help a friend over a very difficult time.