Hi, and thanks for your medical question on eHealth forum!
This is indeed a strange case with the IUD inside for 38 years. During this time the hormonal effect would have been lost. However the IUD could have generated a foreign body reaction. It is difficult to say whether this is the cause for ovarian cancer or not. Generally IUDs decrease the risk of both endometrial and ovarian cancer. Please discuss with the cancer specialist. Hope this helps. Take care!