Virginia's number one and number four banks announced yesterday that they are discussing a merger that would create a giant bank company with assets of $8 billion and nearly 350 branches blanketing the state.

Officials of United Virginia Bankshares Inc., with $4.8 billion in assets, and Dominion Bankshares Corp., with $3.2 billion in assets, disclosed that they have been discussing a possible merger since last October, but declined to elaborate on the terse joint announcement that the two companies "are exploring the feasibility of an affiliation."

The announcement came less than two weeks after Virginia National Bankshares Inc.--the state's second-largest bank--and number five, First & Merchants Corp., agreed to combine. With total assets of about $7 billion, those merged banks would become not only the biggest bank holding company in Virginia but the largest in the Middle Atlantic States.

A combination of United Virginia and Dominion, however, would create an institution about 15 percent bigger than a merged Virginia National and First & Merchants.

A spokesman for United Virginia, which is based in Richmond, denied that the Virginia National-F&M merger triggered its talks with Dominion, which is based in Roanoke.

Sources said that United Virginia and Dominion made their brief announcement yesterday because rumors of the talks had begun to circulate in Richmond.

Neither bank would comment on such issues as why the talks were initiated, who would run the new bank, where it would be based or what impact a combination would have on Virginia banking.

Any merger would require the approval of federal banking regulators and of both banks' boards of directors and shareholders. How stockholders of the banks would be affected by a merger could not be determined yesterday.

The banking industry has been moving steadily toward consolidation not only in Virginia but across the country. For many smaller banks, the only way to survive in an era of costly new technology and increased competition because of deregulation is to affiliate with bigger banks. Even larger regional banks are combining.

On Monday, Ireland's largest bank, Allied Irish Banks Ltd., announced plans to acquire controlling interest in First National Bank of Maryland, a Baltimore-based bank with $3.4 billion in assets. The Dublin bank, which has $8 billion in assets, intends to make Maryland the headquarters for its United States operations.

Until Norfolk's Virginia National and Richmond's First & Merchants announced their merger plans late last month, most bank mergers in Virginia involved large banks taking over small ones. Since Virginia's laws restricting bank mergers were substantially removed several years ago, there has been a flood of large bank acquisitions in the state.

Although both banks have statewide operations, United Virginia's primary territory is Richmond and central and southern Virginia. Dominion is strongest in the southwestern portion of the state and the Tidewater region.

United Virginia has about 39 branches in the Washington suburbs, while Dominion has 23.

United Virginia, for years the state's biggest bank, earned $44.4 million last year, a 14 percent increase over the $38.8 million it earned in 1981. Dominion's earnings dropped to $22.5 million from $23.9 million in 1981.