If collected and stored properly, the sperm can indeed be used after a man has died. As shilolo stated, sperm or egg collection is commonly done when one partner will be undergoing sterilizing chemotherapy or radiation treatments. My husband and I went to a fertility clinic right before he had to go in for treatments. We were only recently married and still wanted to start a family. I imagine the rules vary depending on where you live, but in BC the sperm (or eggs) belong to the donator. The only way that someone else can use the sperm is with the donator’s consent. The only way to transfer ownership of the sperm is to dictate in your will who it will go to, or else to leave a notarized letter of direction regarding the stored sperm. Otherwise, the sperm is destroyed after the donator passes away. The storage contract we signed was crystal clear on that point.
In our case, the sperm was intended to be used for my husband and I to have a family together once he recovered from his illness. When we found out he was terminal, the issue arose of whether to do anything with the sperm after he died. He knew that his family would be delighted if I could have a child by him, even if he was gone – it would be a way of keeping a little part of him around, in a way. There was also the question of me possibly wanting to raise a child of ours on my own. He was willing to will the sperm to me, but was uneasy about it. On one hand, he didn’t want me to have a child just for the sake of his family and knew that they might unconsciously put some pressure on me to do so. He also didn’t like the idea of me struggling to raise a child alone. He felt even more uncomfortable about the idea of some stranger helping me raise his child, assuming I started a life with someone else at some point. The question, in reality, is often much more complicated than just whether it can be done.