Joseph R. Hardiman, chief operating officer of Alex. Brown & Sons Inc. of Baltimore, was chosen yesterday to succeed Gordon S. Macklin as president of the National Association of Securities Dealers, the Washington organization that operates the nation's over-the-counter securities market.

Hardiman, 50, said he would leave Alex. Brown, a major regional brokerage firm, on Aug. 31 and begin working full-time at NASD Sept. 1.

Hardiman has been chairman of the NASD's 31-member board of governors. He withdrew as head of a committee searching for a new chief executive for the organization several months ago to become a candidate for the job himself. He was elected to his new post yesterday by the board of governors on the recommendation of an NASD search committee.

Hardiman joined Alex. Brown in 1975 after working at Robert Garrett & Sons in Baltimore. A lawyer, Hardiman received his law degree from the University of Maryland.

Macklin announced earlier this year that he would resign after 17 years as NASD president to become cochief executive of Hambrecht & Quist, a San Francisco brokerage house that specializes in technology stocks. Macklin said he would keep his Bethesda home and split his time between H&Q's offices in California and New York. He said he may eventually open an H&Q office in Washington.

During Macklin's reign, the NASD's over-the-counter stock trading system became the third-largest stock market in the world after the New York and Tokyo stock exchanges.

Called Nasdaq, after the NASD automated stock quotation system, the market is a network of computers that link 540 market makers around the country who buy and sell 5,500 issues, most of them smaller companies.

Hardiman said the top item on his agenda is to improve NASD's ability to uncover insider trading. An NASD task force, he said, is reviewing the association's electronic surveillance system, which sounds an alarm when a stock shows unusual trading volume or price movement. The stock is then investigated by the NASD staff.

Currently, an NASD official said, the organization is boosting its market surveillance staff from 47 to 65 people. Most of the new employes will be analysts who look into the surveillance alerts.

In 1986, the NASD sent 200 cases involving suspected market manipulation, insider trading and other possible violations of law to the Securities and Exchange Commission for furthu investigation. Many of the cases involved trading in stocks before news affecting those stocks was formally announced.

The NASD task force is headed by attorney A.A. Sommer, a partner in the Washington law firm of Morgan, Lewis & Bockius. Sommer is a former SEC commissioner. His task force is expected to complete its work this year.

Hardiman also said: NASD generally agrees with an SEC proposal to solve the industry controversy over whether companies can have more than one class of stock, including some with restricted voting rights or none at all. The New York Stock Exchange, under its "one share, one vote" rule, bars dual classes of stock, but the American Stock Exchange and NASD have permitted it. The SEC plan would prevent the issuance of classes of stock that dilute the voting rights of existing shareholders.

The NASD, which assists the SEC in regulating the securities industry, will soon begin examining the books of about 60 dealers in government securities. If Congress wants, the NASD is willing to regulate the 12,000 registered investment advisers in the country.

The NASD has asked the SEC to approve a rule that all NASD companies trading on its national market system must have at least two independent directors and that independent directors must comprise a majority of the board's audit committee.

The NASD is studying whether to create a computerized system for handling "limit orders" from their customers. Currently, some NASD firms accept limit orders, others do not. A "limit order" allows a customer to order a broker to buy or sell a security at a specific price or price range.