The FBI yesterday arrested a Los Angeles computer consultant who allegedly stole $10.2 million from a California bank and used most of it to buy diamonds from a Russian agency.

Stanley Mark Rifkin's brief odyssey began on Oct. 25 when he learned the secret code used to transfer funds by Security Pacific National Bank in Los Angeles. It ended early yesterday morning when the FBI agents found him in an apartment in Carlsbad, Calif., north of San Diego.

According to Paul L. Smith, executive vice president of the bank, Rifkin had become familiar to bank employes when he had worked there for a computer firm.

On Oct. 25, Rifkin wandered into a room in the bank where money transfers are handled. From here, funds from Security Pacific are transfered by wire to other institutions around the world.

But before a bank officer can order such a transfer, he must supply his own identification number as well as a transfer code number that changes daily.

While visiting the room, Rifkin allegedly learned the day's code number as well as an officer's identification number. Just after the close of business that day, Rifkin called the room, used the code numbers, and ordered $10.2 million to be wired to a bank in New York for transfer to another bank in Zurich, Switzerland.

With the money deposited in a Swiss account, Rifkin allegedly engaged a Los Angeles diamond merchant to order $8,145,000 in diamonds from Russalmaz, the diamond exporting arm of the Soviet government.

"After confirming Rifkin had $10.2 million in his account, the Russians sold him the diamonds," and FBI spokesman said.

The FBI did not make public the names of the New York or Swiss banks.

During the next few days, Rifkin, 32, using the alias Mike Hanson, among others, flew to Zurich with a phony passport, the FBI said.

Picking up the diamonds, he flew back to the West Coast where the FBI thinks he sold a few small gems to raise some $12,000 in cash which he had when he was arrested.

Security Pacific is seeking to recover the $2 million that Rifkin did not withdraw from the Swiss bank account. The FBI estimated that the diamonds are worth about $13 million on the retail market.

The FBI speculates that one reason Rifkin bought diamonds was because they are also light to carry. "The whole package weighed less than five pounds," said one agent. "It's a pretty package, too - some of the stones are worth $30,000 each."

The FBI said as part of the security system in the money transfer room, orders taken over the phone are tape recorded. Rifkin's diamond broker identified Rifkin's voice from the recording, the FBI said.