According to these two fatwas -in Arabic- (note one is referring to the other) on test-tube fertilization (islamqa and al-azhar) and I try to briefly translate the major statements (please also note that these fatwas include a lot more information about the matter of test-tube fertilization, for example the case of a husband having two wives and whether it is allowed to give a fertilized egg of one wife to the other):
وانفصال الزوجين يكون بواحد من ثلاثة أمور ، الفسخ أو الانفساخ ، والطلاق ، والموت
According to the mawsu'a al fiqhiya: The end or terminal separation between spouses can be due to three things: faskh/infisakh or talaq or death.
إذا توفى الزوج انقطعت العلاقة الزوجية من الناحية الجنسية بالذات بينه وبين زوجته ، ووضع هذه البويضة الملقحة فى رحمها أصبح وضعا لشىء غريب منفصل عنها، فالمرأة صارت غريبة عنه ، ولذلك يحل لها أن تتزوج من غيره بعد الانتهاء من العدة المضروبة لوفاة الزوج ، وهى قبل انتهاء العدة أشبه بالمطلقة طلاقا بائنا، حيث لا يجوز أن تكون بينهما معاشرة زوجية تعتبر رجعة بالفعل فى بعض المذاهب الفقهية، بل لا بد أن يكون ذلك بعقد جديد، وهو فى هذه الصورة غير ممكن لوفاة الزوج ، فلو وضعت المرأة - بعد وفاة الرجل - بويضتها الملقحة منه قبل وفاته فى رحمها وحملت وولدت كان الولد غير منسوب إليه كولد الزنا ، وإنما ينسب إليها هى ، مع حرمة هذه العملية .
ثالثا: إذا توفيت الزوجة فوضعت بويضتها الملقحة من ماء زوجها فى رحم امرأة أخرى التى يطلق عليها اسم "الأم الحاضنة" صاحبة الرحم المؤجَّر كان ذلك حراما ، لما سبق ذكره فى السؤال الأول من أنه زنا، حتى لو سلمت الولد للزوج .
Once the husband has died the (especially the sexual) relationship has ended. So amn in vitro fertilization would be considered as haraam, as her -former. husband and therefore his sperms etc. would be considered as a foreigner and haraam for her. Because once the marriage ended -in this case because of death- she could marry again after the 'idah. And before the end of the 'Idah she is more likely considered as a a divoreced woman (talaq baa'in), so she can only have intercourse with her (former) husband once they got remarried, which is impossible, as he´is dead. So if she however did so, the child wouldn't be considered as his child rather than a child of a non-lawful relationship and should be named after her.
If instead the wife died it's haraam to do an in-vitro fertilzation to an other woman and considered as zina. The scholar 'Atiyyah Saqr عطية صقر who gave this fatwa added, even in case that the woman whom will recieve the fertilzation of an other is an other wife of the same man he'd consider this as not allowed ( أرجح عدم الجواز).
And Allah knows best!