The Securities and Exchange Commission, Becton-Dickson Corp. and the Sun Co. Inc. yesterday agreed to a plan for Sun to dispose of the Becton-Dickson stock it acquired in an illegal takeover attempt last year.

The unique divestiture plan, designed to prevent any other company from buying the stock to be sold by Sun and using it to gain control of Becton-Dickinson, ends a landmark legal case that already has written new rules for corporate takeover fights.

Under the plan, Sun will sell about $390 million worth of debentures that can be converted into Becton-Dickinson stock.

No single investor will be able to buy more than 5 percent of the debentures at the time they first are offered.

Sun will sell the debentures for a premium above the current selling price of Becton-Dickson stock, thus making it unattractive for an investor to buy the debentures and immediately swap then for B-D shares.

Under the agreement, Sun can set the price of the debentures as high as $60 a share. Currently B-D stock is selling for about $33 a share. If the price of B-D stock rises to $60 a share, it will be attractive for debenture buyers to trade them for the stock.

After 10 years, if the debentures haven't been converted into stock, Sun is required to redeem them for cash buying back 6 2/3 percent of the outstanding debentures each year for 15 years.

In that case, Sun will sell the B-D shares back to Becton-Dickinson for at least $49.50 a share.

The complex debenture plan was worked out by lawyers for the two companies, the SEC and the group of B-D shareholders who filed a class action lawsuit against Sun.

The settlement also provides for a cash payment of about $2.6 million to settle the lawsuit. The cash will pay lawyers in that case, then the remainder will be split among the owners of the 8.5 million B-D shares in public hands.

Sun bought about 6.5 million shares of B-D -- 33 percent of the stock -- on two days in January 1978 by calling up a number of large stockholders -- mostly banks and insurance companies -- and offering them several dollars more than the selling price of the stock.

Contending the purchases were illegal because the same offer wasn't made to all shareholders, the SEC sued Sun. Sun's lawyers and investment bankers claimed the telephone takeover was legal because it didn't meet the standard difinition of a tender offer for stock.

But after a long trial, U.S. District Court Judge Robert Carter ruled in New York that Sun's tactic was illegal. Carter must approve the disposition plan agreed to by the companies.