Honestly, the only 100% foolproof way is to not have sex at all. Yes, there are things like condoms, pills, IUDs or even tying of tubes, but nothing else you do can really stop things from happening when it's meant to be.
I have heard about people who got pregnant while having IUDs or even with tubes tied, it's very rare but it's not impossible!