Rusty Staub, two for 21 coming to bat, hit a pinch-hit homer with two out in the ninth yesterday as the Mets beat the San Francisco Giants, 6-5, in New York.

Staub, hitless in his previous 16 at-bats, batted for Craig Swan and hit a 1-0 pitch off reliever Greg Minton (2-2) for his first homer this season. Swan (2-1) pitched 1 1/3 innings for the victory.

The Giants tied at 5 in the eighth when, with two out, rookie Tom O'Malley hit his first major league homer, off reliever Pat Zachry. O'Malley got three hits in only his second big-league game.

Dave Kingman's major-league leading 11th homer, with one on in the sixth, had given New York a 5-4 lead. It upped Kingman's RBI total to 26.

The Giants, trailing 3-0, took a 4-3 lead in the fifth. With two out, Duane Kuiper singled off first baseman Kingman's glove. Alan Fowlkes followed with a hard grounder that bounced off third baseman Hubie Brooks' chest. Both advanced on a wild pitch by starter Pete Falcone, then rookie Chili Davis hit his third homer and, on the next pitch, Jonnie LeMaster hit his first homer since July 12, 1980. Nine of Davis' 14 RBI have come off Mets' pitchers.