Firstly, it's not quite correct to say that UK Government departments were traditionally named Ministries. The common use of the term Ministry to describe government departments was mostly introduced in the first half of the 20th Century. To take your examples:
- Ministry of Transport: established in 1919, assumed duties of the Road Board, and transport-related powers of the Ministry of Health (also established in 1919) and the Board of Trade.
- Ministry of Agriculture, Fisheries and Food: established in 1919, preceded by the Board of Agriculture and Fisheries.
- Ministry of Education: established in 1944, preceded by the Board of Education.
The title of Ministry was predominantly used throughout the 20th century to refer to the difference between Departments, run by a Secretary of State, and Ministries, run by a Minister. The title of Secretary of State outranks that of Minister, and there used to be far fewer of them than the current 16 (there is a limit of 21 salaried Secretaries of State set by the Ministerial and other Salaries Act 1975). Originally, there was just one SoS - as in the USA, for example. This divided in 1689 with the creation of the Secretary of State for the Northern Department and the Secretary of State for the Southern Department. These eventually morphed into the current offices of Foreign Secretary and Home Secretary.
Further Secretaries of State were introduced through the 18th century onwards, and especially in the post-war period. This often came about with a change of department name - for example, the Ministry for Transport was subsumed by the Department of the Environment (and its new SoS) in 1970, but became the Department of Transport with its own SoS in 1976. In the case of the Ministry of Education, this became the Department for Education and Science in tandem with the creation of the post of Secretary of State for Education and Science in 1964.
Some ministries, such as the Ministry of Agriculture, Fisheries and Food that you mentioned, remained as ministries for a long time, with no promotion for their responsible minister to the level of SoS. This sometimes led to perception issues; for example during the Foot & Mouth outbreak in 2001, the government was criticised for not having elevated the ministry to a SoS-level department:
So puny is the standing of the Minister of Agriculture in the Westminster animal kingdom that the holder of the post does not even enjoy the dignity of being called Secretary of State. Successive Prime Ministers, reflecting the indifference of the electorate to how their daily grub is produced and delivered, have treated the position as the nether end of the Cabinet's biological chain.
The Ministry of Agriculture, Fisheries and Food went on to merge with part of the Department for Environment, Transport and the Regions to become Department for Environment, Food and Rural Affairs in late 2001, along with the creation of the post of Secretary of State for Environment, Food and Rural Affairs.
However
Some government departments were given the 'Ministry' name despite being headed by a Secretary of State - the Ministry of Defence, and the Ministry of Justice. I believe this came about because these bodies were formed by combining departments that were already led by Secretaries of State - the Ministry of Defence was formed from the Admiralty, the War Office, and the Air Ministry, and the Ministry of Justice replaced the Department for Constitutional Affairs.
Most recently, the Department for Communities and Local Government was renamed to the Ministry of Housing, Communities and Local Government, but remained led by a Secretary of State. This may have been to evoke comparisons to Harold Macmillan's famously successful program of house building as the inaugral Minister of Housing & Local Government. A Freedom of Information request on this topic received the following response:
The Ministry for Housing, Communities and Local Government remained a
government department when its name changed in January 2018. Other
government departments which are also called "ministries" include the
Ministry of Defence and the Ministry of Justice.
Bringing "Housing" back into the department’s title for the first time
since the 1960s, reflected the Government’s renewed focus to deliver more
homes and build strong communities across England.
In particular, it demonstrated the Government’s increased ambition on
housing – with new commitments on housing supply, homelessness and rough
sleeping and social housing, together with other reforms to improve the
experience of those who buy and rent homes.
The Ministry was renamed back to a Department in 2021; the Department for Levelling Up, Housing and Communities.
In these instances, there is no difference between a Ministry and a Department except stylistically - they are all fully-fledged government departments led by a Secretary of State.