Relax :)
Things like that happen, and I am sure that person is aware that you couldn't have known about her grandmother's passing.
You didn't even make a terrible joke or anything, so don't worry at all. You can't prevent stuff like this from happening sometimes. We can't manage all our words and assume that something could inadvertently make someone feel bad or offended. The important part is just apologizing and letting that person know that you feel and care for her! That's worth a lot more than anything. If anything, the joke you made opens up a topic of conversation that she may have wanted to engage in for a long time. After all, grief is hard to deal with alone, so maybe you can now do more good than you could have initially as a result of this 'accident'.
Either way, as long as you are a good person, a mistimed expression or joke like this means very little.