"The Maryland delegation better not sing 'Maryland, My Maryland' in front of Rostenkowski," Rep. Barney Frank (D-Mass.) said yesterday as he left the House floor, after a surprising defeat for the tax revision measure championed by Rep. Dan Rostenkowski (D-Ill.) and President Reagan.

Many House members said Maryland and Virginia representatives, upset over increased taxation of federal workers' pensions, played a key role in yesterday's derailment of the massive rewriting of the tax code.

"Federal workers is to Maryland what the oil and gas industry is to Texas," said Rep. Barbara B. Kennelly (D-Conn.), a member of the Ways and Means Committee headed by Rostenkowski.

Ways and Means Committee member Rep. Thomas J. Downey (D-N.Y.), who said he was "shocked" by the defeat, said a major factor was that "a number [of representatives] felt that federal employes had to be dealt with first. We lost the Maryland delegation and a number of the Virginia congressmen."

The House did not vote on the actual tax bill, but on the rule setting the guidelines on how the bill should be considered. When the rule was defeated, 223 to 202, the tax bill had to be pulled abruptly from the floor, while supporters reviewed their strategy.

Last night, supporters said that if Reagan rounded up enough Republican votes the bill would be brought up again some time this week, meaning the victory for opponents could be short-lived. But Rep. Stan Parris (R-Va.) said he was still confident: "That vote was no accident."

All eight members of the Maryland delegation voted against the rule. The six Virginia Republican members of Congress voted to defeat the rule, while the four Democratic members voted to approve it.

House Ways and Means Committee members estimated that they lost seven to 10 Democratic votes solely because of the federal employe issue, and there was no estimate on the number of Republican votes lost. But House members said that the federal employe issue provided an emotional rallying cry, around which opponents could coalesce.

Rep. Michael Barnes (D-Md.) was one of the Democrats who the Ways and Means Committee had expected, until Tuesday night, to support the bill, according to Rep. Robert T. Matsui (D-Calif.). As late as Tuesday afternoon, Barnes was undecided. He told a reporter that he had been lobbied to support the bill by 10 committee members. "They've been all over me," said Barnes, who finally opposed it because of the federal employe issue.

Under the current system, federal employes must contribute 7 percent of their income to their pensions. Because they pay income taxes on their contributions, they are allowed to draw money from their pension, tax-free, for the first three years after retirement. They then must pay taxes on their annuity payments.

The Ways and Means Committee bill would require federal employes to pay taxes immediately, but on only a portion of their annuity payments. The changes would also affect state and local employes, and some private pensions funds.

Rostenkowski said he was opposed to deleting the measure, because it would reduce tax revenues by $8 billion.

Parris, Rep. Frank Wolf (R-Va.) and Rep. Steny Hoyer (D-Md.) asked the Rules Committee to permit them to offer an amendment striking the federal employe provision from the bill. But Tuesday night the committee turned them down.

Yesterday morning, Parris and House Republican leaders who had parted ways with Reagan on the bill decided to try to defeat the rule. They also decided that the public employe issue would be a good political vehicle to use. Several Republican leaders took the floor, saying the House should give better treatment to senior citizens, postal employes, firefighters and other public employes.

Wolf boomed from the podium as he pounded his fists, "It's unfair. Americans don't know what's in this bill." And when the 'nay' votes reached 219, there was a big cheer from the floor, as one congressman yelled out, "Who said that federal employes aren't powerful?"