PepsiCo Inc. said today it has agreed to buy most of Seven-Up Co. for $380 million in cash, a deal that would make PepsiCo nearly as big as the No.1 producer of soft drinks, Coca-Cola Co., and leave smaller producers farther behind than ever.

PepsiCo's purchase of Seven-Up, the nation's third-biggest soft-drink company, from Philip Morris Inc. would cover the Seven-Up trademark and worldwide franchises.

The agreement does not cover its 16 North American bottling plants or its foods group. Philip Morris said it intends to sell those businesses separately "in the near future," and spokesman George Knox said the company hopes to break even on the deal overall. Philip Morris, a tobacco and consumer products conglomerate, bought Seven-Up for $520 million in 1978 and has lost money on it in recent years.

Analysts said that, if the Seven-Up deal passes a government review for antitrust considerations, it almost locks out the chance that any other company could emerge as a third major player in the soft-drink business.

"It's more of a Goliath and Goliath game, and it's going to be harder for the Davids of the world," said Lee D. Wilder, a beverage-industry analyst at Robinson-Humphrey Co. in Atlanta.

Together, Coca-Cola and PepsiCo gradually are squeezing out smaller competitors in the soft-drink business, while soft drinks themselves are squeezing out beer, milk and even tap water from the public's diet, said analyst David Goldman of Dean Witter Reynolds Inc.

Americans drink about 42 gallons of soft drinks a year, and their consumption is growing about by 5 percent a year, according to Jerry Stevens, editor-in-chief and publisher of Beverage World magazine.

The announcement of the merger agreement came one day after Coca-Cola USA's introduction of a new line of Minute Maid soft drinks containing fruit juice and vitamins.

Coca-Cola also will be stepping up its marketing support for Sprite and its diet version, making direct taste comparisons with Seven-Up, according to Brian G. Dyson, president of Coca-Cola USA.

Pepsi-Cola USA has had the juice-added, lemon-lime drink Slice on the market for about a year and announced earlier this week that it began the national introduction of Mandarin Orange Slice, an orange-flavored drink.

By combining Seven-Up and Slice, PepsiCo would take a dominant position in the increasingly important market for citrus-flavored drinks. That segment -- including Seven-Up, Sprite and the new juice-added soft drinks -- accounts for about 20 percent of soft-drink sales and eventually may capture 25 percent of the market, Coca-Cola's Dyson estimated.

Coca-Cola has about 39 percent of the $26 billion wholesale soft-drink market, while PepsiCo would have about 34 percent of the market once it took over the 6 percent market share held by Seven-Up, Goldman said.

The Justice Department or the Federal Trade Commission must review the proposed merger to see if it would reduce competition and violate the Clayton Act. The FTC is expected to handle the deal because it usually reviews cases in the food and beverage industry.

Spokesmen at the two agencies declined comment today. Beverage-industry analysts generally said they expect the deal to receive government clearance because the Reagan administration has been tolerant of mergers that might have raised antitrust questions in other administrations. "My own opinion is that the climate in Washington is such that this will pass," Stevens said.

Seven-Up had gradually mounting losses under Philip Morris ownership, including operating losses of about $10 million in 1985 alone, but PepsiCo should be able to make money on Seven-Up, Goldman said.

"Seven-Up is a top-quality product that has the potential to become one of the most popular soft drinks in the world," PepsiCo said in a news release. Spokesman James Griffith said PepsiCo would put its full marketing muscle behind Seven-Up to build its share of the market.