In its second transaction in less than a week, SLB Ltd. agreed Tuesday to buy ChampionX Corp., considered a leader in oilfield reservoir optimization.

The all-stock merger with ChampionX, headquartered in The Woodlands north of Houston, was valued at nearly $8 billion. Once the transaction is completed, now expected by year’s end, ChampionX shareholders would own about 9% of SLB, which already is the largest oilfield services operator in the world.

The acquisition of ChampionX “comes at an important time in the industry,” SLB executives said. “The production phase of oil and gas operations typically comprises the majority of an asset’s lifecycle from completion through decommissioning. This places a premium on service providers’ ability to help customers address...