Answer by taking a quote from the following article:

Pieter Willem Botha, DMS (Afrikaans pronunciation: ['pit@r 'v@l@m 'bU@ta]; 12 January 1916 - 31 October 2006), commonly known as "P. W." and Die Groot Krokodil (Afrikaans for "The Big Crocodile"), was the leader of South Africa from 1978 to 1989, serving as the last Prime Minister from 1978 to 1984 and the first executive State President from 1984 to 1989. First elected to Parliament in 1948, Botha was an outspoken opponent of majority rule and international communism. However, his administration did make concessions towards political reform, whereas internal unrest saw widespread human rights abuses at the hands of the government. Botha resigned the leadership of the ruling National Party in February 1989 after suffering a stroke and six months later was coerced to leave the presidency as well.

At age 30, Botha was elected head of the National Party Youth in 1946, and two years later won a race for the House of Assembly as representative of George in the southern Cape Province in the general election which saw the beginning of the National Party's 46-year tenure in power. In 1958 Botha was appointed Deputy Minister of Internal Affairs by Hendrik Verwoerd, and in 1961 advanced to Minister of Coloured Affairs. He was appointed Minister for Defence by Verwoerd's successor B.J. Vorster, upon Verwoerd's murder, in 1966. Under his 14 years as its leader, the South African Defence Force reached a zenith, at times consuming 20% of the national budget, compared to 1.3% in 1968, and was involved in the South African Border War. When Vorster resigned following allegations of his involvement in the Muldergate Scandal in 1978, Botha was elected as his successor by the National Party caucus, besting the electorate's favourite, 45-year-old Foreign Minister Pik Botha. In the final internal ballot, he beat Connie Mulder, the scandal's namesake, in a 78-72 vote.  Botha was keen to promote constitutional reform, and hoped to implement a form of federal system in South Africa that would allow for greater "self-rule" for black homelands (or Bantustans), while still retaining the supremacy of a white central government, and foremost expand the rights of Coloureds (South Africans of mixed ancestry) and Asians in order to widen support for the government. Upon enacting the reforms, he remarked in the House of Assembly; "We must adapt or die."  On becoming head of the government, Botha retained the defence portfolio until October 1980, when he appointed chief of the South African Defence Force, General Magnus Malan, his successor. From his ascension to the cabinet, Botha pursued an ambitious military policy designed to increase South Africa's military capability. He sought to improve relations with the West - especially the United States - but with mixed results. He argued that the preservation of the apartheid government, though unpopular, was crucial to stemming the tide of African Communism, which had made in-roads into neighbouring Angola and Mozambique after these two former Portuguese colonies obtained independence.  As Prime Minister and later State President, his greatest parliamentary opponents were Harry Schwarz and Helen Suzman of the Progressive Federal Party until 1987, when his former cabinet colleague Andries Treurnicht's new Conservative Party became the official opposition on a strictly anti-concessionist agenda.  In 1977, as Minister of Defence he began a secret nuclear weapons program, which culminated in the production of six nuclear bombs destroyed only in the early 1990s. He remained steadfast in South Africa's administration of the neighbouring territory South-West Africa, particularly while there was a presence of Cuban troops in Angola to the north. Botha was responsible for introducing the notorious police counter-insurgency unit, Koevoet. He was also instrumental in building the South African Defence Force's strength. Adding momentum to establishing units such as 32 Battalion. South African intervention in support of the rebel UNITA (Dr. Jonas Savimbi, a personal friend) movement in the Angolan Civil War continued until the late 1980s, terminating with the Tripartite Accord. To maintain the nation's military strength, a very strict draft was implemented to enforce compulsory military service for white South African men.

How long was he a Minister for Defence?
14 years