Hogan and Spellman. For 12 years, these were the magical names in Prince George's County's most successful Republican, first as a congressman and later as the county executive. Gladys Spellman was his Democratic counterpart, the ebulient grandmother who replaced him in Congress and was elected to serve there for four terms. It probably could have been a lifetime had she not been stricken by heart failure last October.

But yesterday, resoundingly, the county's voters made it clear that the magic was in the person, not in the name. The power was not to be transferred to son or husband.

Lawrence J. Hogan Jr., pink-cheeked and 24, tried to follow in his illustrious father's footsteps. He fell flat on his face, losing to Bowie Mayor Audrey Scott in the Republican congressional primary by an overwhelming margin, a margin so great that the young man was forced to concede only 45 minutes after the polls closed.

Reuben Spellman, husband of the hospitalized Gladys and a political novice at age 71, fared relatively better than Hogan Jr., but not well enough. He lost to golden-haired Steny Hoyer in the Democratic primary by several thousand votes.

What happened to the magic is a matter of political speculation. Some voters leaving the polls said that Spellman was too old, that Hogan was too young. Some voters said it was presumptuous of the husband and son to assume that the congressional seat was in any way a family affair. Both Hogan and Spellman were gracious losers last night, each evoking the lessons taught them by the original bearers of their political names.

"One of the things Gladys always said was 'In order to be a good winner, you have to learn to be a good loser,'" said Reuben Spellman as he stood atop a chair in his Greenbelt campaign headquarters, looking down on a tearful gathering of supporters. "We can be good losers now."

Spellman said he would work eagerly now for Hoyer. He didn't say that his short and belated political career was over, but few politicians have come back from initial defeats at such and advanced age.

Young Hogan, on the other hand, told a saddened gathering at the American Legion hall in Cheverly that, while he would support Scott in the general election, his own political career was far from over. "I can remember very vividly the first congressional campaign I was involved in in 1966," said Hogan, his voice quivering. "It was my father's first race. He lost, but he didn't give up. He came back and he was elected overwhelmingly to Congress."

The results last night and interviews with voters leaving the polls indicated that Spellman was helped somewhat, but not enough, by his name, by the fondness many Prince Georgians hold for his stricken wife. That did not appear to be the case with young Hogan. In fact, his father may have hurt him more than he helped. The Senior Hogan has made many Republican enemies during his tenure as county executive, enemies who saw his son's candidacy as an easy target for revenge.

There were some gloating Republicans at the Scott victory celebration last night. Poltical figures who have rarely had the courage to tell the elder Hogan what they think of him to his face were seen joking about how they had, in the words of one, "whipped" him. Young Hogan had a swift rejoinder to that kind of boasting. "He wasn't running in this race," said the son of his father."He wouldn't lose an election in Prince Geoge's County."

Young Hogan, embraced and comforted in defeat by his mother, Nora, acknowledged that his campaign was troubled by bickering over whether his father had attempted to remove Scott from a county job during the campaign. The senior Hogan released a "truth sheet" late in campaign denying too late to help. He insisted that age, not bloodlines, did him in.

Despite yesterday's stunning defeat, the Hogan era seems far from over. The son says he may run again in 1982, and the father is expected to either seek reelection that year or run for the U.S. Senate seat.

For the Spellmans, this is no doubt the end. "It's hard to leave," said Francis B. Francois, the former county councilman who was Gladys Spellman's closest political associate for two decades of public service in Prince George's. "It's an end of an era. The spellman era. We walk out as we walked in -- with little people and not much money."