Alexander Ogg was the son of Charles Ogg, a farmer, and his wife Ann Farquharson. He studied at the University of Aberdeen, where he qualified as Bachelor of Science (BSc) and Master of Arts (MA) with honours in mathematics, physics and chemistry. With the help of a scholarship he continued his studies at the University of Goettingen, Germany, where he was awarded the degree Doctor of Philosophy with distinction. His thesis, Ueber das chemische Gleichgewicht zwischen Amalgamen und Loesungen (Leipzig, 1898, 31p) was based on two papers by him in the Zeitschrift fuer Physikalische Chemie (1897-1898). He next spent some time in Leipzig, where he translated Vorlesungen ueber Thermodynamik, by Max Planck, into English as Treatise on thermodynamics (3rd ed. 1927). For some time he was a lecturer in natural philosophy (physics) at the University of Aberdeen, and from 1900 to 1905 was lecturer in physics and applied mathematics at the Royal Naval Engineering College at Devonport, in the south-west of England.
Ogg came to the Cape Colony in May 1905 to become the first professor of physics and applied mathematics at Rhodes University College, Grahamstown. He soon became known as an excellent teacher and organiser, and with his own hands converted part of the old military barracks in which his department was housed into a proper physical laboratory. He attracted the best honours students, many of whom earned overseas scholarships and came to occupy leading positions in the South African scientific community. The University of the Cape of Good Hope (the only degree-awarding institution in southern Africa at this time) admitted him to its MA degree in 1906, on the basis of his degrees from the University of Aberdeen. From 1905 to 1916 he was an examiner in physics and chemistry for this university at various times, and from 1916 to 1918 was a member of its council. In 1910 he married Gertrude E.W. Harvey, with whom he had two daughters.
In 1917, during World War I (1914-1918), Ogg assisted Sir William Bragg in England for some time in military research. From later that year to the end of 1919 he was professor of physics at the South African School of Mines and Technology (soon to become the University of the Witwatersrand) in Johannesburg. During 1919, following the death of the principal, Professor Corstorphine*, he served as acting principal. From 1920 to his retirement in July 1936 he was professor of physics at the University of Cape Town. When the university moved to Groote Schuur he planned and supervised the establishment of the De Beers Physical Laboratory. One of his interests was X-ray crystallography, on which he published some papers. One of these was "Crystalline structure of antimony and bismuth" (Transactions of the Royal Society of South Africa, 1922, Vol. 10, pp. 75-80). A later paper by him in the same journal was "On the electrostatic deflection in a cathode ray tube" (1919-1920, Vol. 8, pp. 21-27).
From the late nineteen-twenties Ogg was mainly interested in terrestrial magnetism and eventually became South Africa's foremost researcher in this field. In 1932 he took charge of a magnetic station established at the University of Cape Town at the request of the International Commission for the Polar Year 1932-1933. The station was equipped with magnetometers for absolute measurements loaned by the Carnegie Institution, Washington, and registration equipment provided by the International Commission for the Polar Year. Volunteers from the staff of the Physics Department began making observations on 5 August 1932. Following representations by the International Commission for the Polar Year and by the International Union for Geodesy and Geophysics, the South African government agreed to finance the station for a further five years. In 1937 the facility was taken over by the newly created Geophysical Branch of the Trigonometrical Survey, and Ogg was appointed as its director. His work included the planning of a new magnetic observatory and the establishment of a network of stations for measuring secular changes in earth magnetism throughout South Africa. The Magnetic Observatory at Hermanus, Western Cape, was built in 1940 and Ogg remained its director until his final retirement in April 1946, at the age of 76. The station became well known internationally for its accurate observations. From 1941 to 1946 Ogg published six papers on magnetic disturbances and K indices of magnetic activity, three each in Terrestrial Magnetism and Atmospheric Electricity and in the Transactions of the Royal Society of South Africa. Earlier he had already described (with B. Gotsman and K.W. Simpson) "The Quartz Horizontal Intensity Magnetometer" in the latter journal (1938, Vol. 26, pp. 395-401). His work put systematic geomagnetic research in South Africa on a firm footing.
Ogg was a Fellow of the (British) Institute of Physics, the Physical Society, the Royal Microscopical Society, and the Faraday Society. Locally he joined the South African Philosophical Society in 1906 and was elected a foundation Fellow of its successor, the Royal Society of South Africa, in 1908. He served on the society's council from 1919, and as president for 1923-1924 and again for 1929-1930. He joined the South African Association for the Advancement of Science in 1907, serving on its council from that year and as president of Section A (which included physics) in 1913-1914. In 1935 the University of Cape Town conferred on him an honorary Doctor of Science (DSc) degree. The next year he was awarded an honorary Doctor of Laws (LLD) degree by the University of Aberdeen. As a person he was remembered for his kindliness and humour, and for the personal interest he took in his students.