Defense Secretary Ashton B. Carter believes he has come up with a way to help the Pentagon retain troops: freezing sperm and eggs. As part of an initiative to make military service more appealing and family friendly, Mr. Carter has created a pilot program that will pay for troops to have their reproductive cells preserved.