Brunei, a small oil-producing country on the northwest coast of the land of Borneo, will become an independant nation in 1983, the British Foreign Office announced yesterday.

Britain currently is responsible for Brunei's external affairs and defense, a holdover from colonial days. Brunei was made part of the British Empire in 1906 after having been under British protection since 1888.

A battalion of 800 British Gurkha troops serving in the oil-rich Southeast Asian state will remain there until September 1983, according to the Foreign Office.

Agreement on theindependence issue was reached after 12 days of talks between Brunei's leaders, Sir Muda Hassanal Bolkiah, and Foreign Office Minister of State Lord Goronwy-Roberts.

The Foreign Office said the recent talks were conducted "in the spirit of close friendship which characterizes the longstanding and traditional relationship between the two countries and which both countries wish to continue."

The agreement is to be initiated in London this September and signed in Brunei in December.

Brunei, which is about the size of the state of Delaware, occupies 2,226 square miles of Borneo and borders on the South China Sea and the Malaysian state of Sarawak. It has a population of about 163,000.

In the early 19th century, Brunei was a haven for pirates and a market for the slave trade, but that ended with the coming of the British in the latter half of the century.

In 1906, the Sultan of Brunei handed over administration to the British, an arrangement which remained until the Japanese invasion in December 1941, Brunei was liberated in 1945 and returned to British control.

Until oil was discovered in the 1920s, Brunei was the improverished remnant of a once-powerful Moslem empire.

Oil has pumped life back into Brunei. Brunei Shell, co-owned by the government and Royal Dutch Shell, is producing about 230,000 barrels a day and is the second-largest producer after Indonesia in Southeast Asia.

The oil revenue, $902 million last year, permits the sultan to treat his subjuects well. Among other benefits, citizens of Brunei pay no income tax and enjoy free medical care, pensions and education through university level.