Walmart Inc. is in preliminary talks to buy insurer Humana Inc., according to people familiar with the matter, a deal that would mark a dramatic shift for the retail behemoth and the latest in a recent flurry of big deals in health-care services.

It isn’t clear what terms the companies may be discussing, and there is no guarantee they will strike a deal. If they do, the deal would be big: Humana currently has a market value of about $37 billion.

It...