John M. Fedders, the former enforcement director of the Securities and Exchange Commission, testified yesterday that he fled to a Trappist monastery and sought psychiatric counseling after public disclosure of allegations that he beat his wife and ran up huge debts trying to support an affluent life style.

In a voice often choked with emotion, Fedders said during a divorce hearing in Montgomery Circuit Court that he sent his wife flowers and wrote her love letters to persuade her to reconcile with him after more than 27 months of legal separation.

Fedders, 43, a prominent Washington attorney before being appointed to the SEC by President Reagan, separated from his wife Charlotte in 1983. Testimony yesterday ended the two-day hearing. Judge James S. McAuliffe said he would interview the children privately and hear final arguments before rendering a decision in the case today.

In a legal memorandum filed Monday, John Fedders asked the court to dismiss his wife's petition for a divorce and custody of the children and to order psychiatric counseling for all parties aimed at achieving a reconciliation.

In testimony yesterday, he said reconciliation had always been his goal even though he had little contact with his family since he and his wife separated.

After he quit his SEC job in February, he said he decided to renew his spiritual life, and redirect his personal life through counseling. He began seeing a psychiatrist, spent a week at a Trappist monastery in Virginia and joined a men's self-help group, he said.

During the last Easter weekend, he testified, he and his wife embraced after a long talk and had sexual relations for the first time in more than two years. After that, they spent several nights together, he said.

As the relationship began to improve, he said, his three oldest children, who had refused to even speak with him on the telephone, also started to change their behavior toward him.

In one of the most emotional moments of yesterday's hearing, Fedders played a tape recording made by three of his children a week before the reconciliation ended.

"I just called to say I love you . . . . You're a great guy; you just have to keep up the good work," one child said.

"I felt there was growth; I was trying," Fedders testified yesterday. "Charlotte and I wanted it to work . . . . I was reaching out, seeking a new direction in my life."

But his wife suddenly broke off their relationship.

In testimony in closed court Monday, which was made public yesterday, she described why their reconciliation effort came to an end. "He continues to make me question myself," she said.

"He continues to make me slide backward. Even without the physical abuse there were many things that I felt were detrimental to my mental health."

Charlotte Fedders said her husband made "major, major promises" on how he would change, but after they renewed their relationship he started to complain about "fingerprints on the wall," her hair color and often dwelt at length on "vivid descriptions of his bodily functions."

"The pattern of our whole life . . . was the entire textbook cycle [of spouse abuse]. This was part of the cycle. John had always promised things, and I would take him back," she testified.

Despite 18 years of marriage, five children and a life style that befitted John Fedders' six-figure salary, Charlotte Fedders described herself in testimony as the "classic abused wife" who suffered in private while her husband rose in prominence.

Over the years, she said her husband's fits of violence left her with a broken eardrum, wrenched neck and several black eyes and bruises.

Fedders resigned from the SEC three weeks after reports of their stormy marriage were published in the news media.

The publicity came at a time when the Reagan administration was pledging to intensify its drive against "horrible crimes like sexual abuse and family violence."

Fedders is now a partner in the Washington law firm of Miller, Cassidy, Larroca and Lewin.