A 29-year-old Southwest Washington man who prosecutors said was the head of a heroin and cocaine distribution ring that accepted telephone orders for drugs was sentenced yesterday by a federal judge here to five years in prison.

James R. Shaw of 101 Sixth St. SW, who pleaded guilty to conspiracy to distribute heroin and to using a telephone to further the conspiracy, received the longest sentence of the 13 persons who were indicted.

Roger M. Cobble, 28, of 3853 Ninth St. SE, who pleaded guilty to a drug distribution charge, was sentenced Wednesday to four years in prison, with all but six months suspended. That time is to be spent in a work-release program.

All of the persons indicted along with Shaw and Cobble also have pleaded guilty to various charges.

U.S. District Judge Thomas F. Hogan, who sentenced all 13, noted that most persons connected with the ring did not have previous criminal records and were employed full time.

The investigation of the drug distribution ring, dubbed Dial-a-Dope, began after drug dealer Joseph McCrea was slain in November 1984 by a man dressed as a mailman. When police searched McCrea's Southeast home, they discovered more than $2 million worth of goods and cash, including several hundred thousand dollars, drugs, furs and jewelry. No one has been arrested in McCrea's death.

Shaw, who police said had worked for McCrea, soon set up his own drug ring, which officials quickly placed under surveillance.

Sources said that Shaw's operation was not major and went undetected for a time because many deliveries were made by joggers, while police were looking for deliveries by car. A court-ordered wiretap produced most of the evidence that was used to obtain the indictment.