A federal judge, acting in the wake of two stabbing deaths at the maximum security facility at Lorton Reformatory, fined the District government $5,000 yesterday for failing to obey a 1980 court order requiring that metal detectors be installed there to protect inmates.

U.S. District Judge June L. Green ordered that the $5,000 be paid to maximum security inmates "since they are the ones who have suffered as a result of this neglect."

In 1980, Lorton's maximum security inmates won $600,000 in damages from the District in a suit claiming that security conditions in the maximum security facility violated their constitutional rights against cruel and unusual punishment. That case is now in the U.S. Court of Appeals.

Green's decision yesterday to hold the city in contempt of court came one week after maximum security inmate Otis Peterson, 25, was stabbed to death on his way to a dining area for breakfast. Two sword-like "shanks," made from steel rods, were found by investigators near where the attack occurred.

Peterson's murder was the second stabbing death in two months at the maximum security facility, where the city's most dangerous convicted criminals are confined.

Lorton officials testified at a hearing yesterday that technical problems, still not resolved, have delayed installation of the detectors, which were delivered to the prison in February 1981.

Under an order issued by Green in connection with the 1980 case, the city was required to place the detectors at the entrance to each cell block of the maximum security facility. Officials said the technical problems developed when they discovered that the cell block door frames contained heavy metal that would cause interference with the detectors' operation.

Metal detectors already are used at the entrance to the maximum security compound.

Attorney Peter J. Nickles, representing the inmates, agreed that the "system" was to blame for delays in complying with security measures, which he described as the "heart and soul" of Green's l980 order. "The system has to be jolted . . . it's the only way the system seems to react," Nickles said in urging Green to hold the city in contempt.

Nickles and other lawyers from the firm of Covington & Burling, representing the inmates at no charge to the inmates, have argued that homemade weapons and other contraband, including shanks, lead pipes and razor blades, are a major source of violence in the maximum security cell blocks.

In court papers, the attorneys said that an inmate was stabbed and critically wounded in a maximum security cell block last October and a second man, who was in protective custody, was cut by a metal shank during an attack staged by other inmates in January. City lawyers and Lorton officials have said the injured inmate may have been armed as well.

A corrections department spokesman said yesterday that there was a total of 71 assaults in the maximum security facility, involving inmates and in some cases prison staff, in fiscal year 1981, compared with 51 assaults in fiscal year 1980 and 66 assaults in fiscal year 1979.

Green said yesterday that while the city has attempted to comply with her order, there have been delays "which were solely due to the District of Columbia's neglect of duty." Green, in a written order, said that when she visited the maximum security facility last October, she had been assured that installation problems would be resolved within a few weeks. "To date the metal detectors still have not been installed," Green wrote yesterday.

In her decision yesterday, Green also ordered the city government to pay fees for the inmates' lawyers, to cover the cost of their monitoring the city's compliance with Green's 1980 order.

Green declined a request from the inmates' lawyers that the city be fined on a daily basis until the metal detectors are installed. She said she would withhold action on that issue until the city submits a plan next week for solving the installation problems connected with the metal detectors.

Green's order requiring installation of the metal detectors was issued in conjuction with the lawsuit brought by the inmates in June 1980. Following the jury's award of damages, Green directed the city to take a variety of security measures at the maximum security facility. The city was obliged to carry out Green's order pending the outcome of the appeal of the 1980 suit. An audio-visual monitoring system was installed in the facility late last year--a security measure that officials said yesterday has cut down on violent incidents within the cell blocks.