Sandford entered the Education office in 1848, where he was to remain except for short interludes until 1884. In 1862 he was organising secretary for the International Exhibition of that year and from 1868 to 1870 he was Assistant Under-Secretary at the Colonial Office. In 1870 he was made Permanent Under-Secretary of State for the Committee of Council on Education. He played an important role in the implementation of the Elementary Education Act of 1870 introduced by William Edward Forster. Sandford combined this role with that of secretary to the Scottish Education department and to the science and art department, offices which were later split between separate individuals. According to the "Dictionary of National Biography" the "...work he performed in these capacities was appreciated by statesmen of all political parties".