Foster was educated at Winchester College and the Royal Military College at Sandhurst, graduating as a Gentlemen Cadet. He was commissioned as a second lieutenant in the Royal Fusiliers on 19 July 1916, but was seconded to the Royal Flying Corps, and on 7 October 1916 was appointed a flying officer. He was sent to France to join No. 54 Squadron flying the Sopwith Camel. While with 54 Squadron, Foster shot down at least one enemy machine. Later in the war Foster returned to Great Britain, carrying out home defence duties whilst serving with No. 44 Squadron. On 19 January 1918 he was promoted to lieutenant. In April 1918, Foster returned to France, serving as a flight commander with the rank of temporary captain from 15 May, in No. 209 Squadron where he claimed three shared enemy aircraft captured, nine shared enemy aircraft destroyed, and four shared enemy aircraft 'out of control', giving a total of 16. On 2 August 1918 Foster was awarded the Distinguished Flying Cross, his citation reading:
Inter-war years
On 1 August 1919 Foster was granted a permanent commission in the Royal Air Force with the rank of lieutenant, resigning his commission in the Royal Fusiliers the same day. In late 1919 he was posted to India where he joined No. 20 Squadron as a pilot. On one occasion during his nearly four years in India, after suffering an aircraft fire, Foster and his observer had to make a forced landing and they were subsequently captured and held for three weeks before being released. On 1 January 1924 he was promoted from flying officer to flight lieutenant. In May 1925 Foster attended the RAF Staff College and the following year he spent several months at the School of Oriental Studies in London. After this period of study, Foster spent the remainder of the 1920s carrying out intelligence duties at the headquarters of RAF Iraq Command. From 1930 Foster once again served as a pilot, this time with No. 70 Squadron. After promotion to squadron leader in December 1932, Foster took up the post of Officer Commanding No. 15 Squadron the next year. In 1935, Foster returned to Iraq, serving on the air staff at the British Forces headquarters where he received promotion to wing commander on 1 July 1937. His last tour before the outbreak of the Second World War was in the Deputy Directorate of Plans on the Air Staff.
Second World War
Only days after war was declared, Foster was posted as the Senior Personnel Officer at the headquarters of No. 2 Group. Late 1939 saw Foster appointed Officer Commanding No. 110 Squadron, and in 1940 he was the Station Commander at RAF Wyton. In January 1942 Foster took up command of No. 214 Group, part of Middle East Command, based at Kirkuk, Iraq, and in November that year he received an acting promotion to air commodore and was posted as Air Officer Commanding No. 213 Group based at Aley, Lebanon. From March 1943, Foster was engaged in staff duties at Mediterranean Air Command before being appointed AOC RAF Malta a year later and receiving acting promotion to air vice marshal. Later in 1944 he served as Head of the Air Commission in Italy which effectively granted him command of the Italian Air Force. Foster did not spend long as Head of the Air Commission, being posted as AOC Desert Air Force in North Africa in December. Following the defeat of the Germany, from August 1945, Foster served on the Allied Commission for Austria as the Chief of the Air Division. Only days later the post became AOC RAF Austria.