Gallagher was born at Dunwiley House, Stranorlar, County Donegal, the youngest child of Henry Thomas Gallagher and his wife Eileen. His father was crown solicitor for County Donegal and co-founder of Urney Chocolates, which the family had established at Tallaght outside Dublin in 1920. Educated at Belvedere College in Dublin — where he captained the school rugby team to the Leinster schools junior cup in 1929 — Gallagher originally hoped to qualify as an engineer but joined the Urney business at his father's insistence. He was sent to Germany in 1934 to learn the chocolate manufacturing trade, working in factories in Dresden and Halle. His earliest motorsport connection came when, aged fifteen, he served as a steward at the Irish Grand Prix in the Phoenix Park.
From 1935 Gallagher participated regularly in Irish motor-racing events. An early crash left him with a broken neck that went undiagnosed for many years. In 1936 he fitted a Ford V8 engine into the chassis of a Bugatti and dubbed the resulting car the Urney Special Racer (USR), building the conversion with the help of Urney's chief engineer. The USR made its racing debut at the 3rd Leinster Trophy at Tallaght in July 1936 and in September of that year Gallagher broke the outright record at the Kilternan Hill Climb. He subsequently sold the car in 1937 to Bill McQuillan, who continued to race it successfully.
After fuel shortages halted his racing during the war years, Gallagher resumed competition in the late 1940s. In collaboration with Urney engineer Nicholas Flynn, he built a series of cars modelled on the Cooper design, calling them the Leprechaun — a nod to the company's advertising. He entered the 1951 Formula One season, driving the Leprechaun II at the British Grand Prix at Silverstone. The 1000cc Leprechaun III proved the most competitive of the home-built machines, winning a number of speed events. During this period he competed alongside and against prominent drivers including Stirling Moss and Juan Manuel Fangio.
Gallagher later acquired a two-seater Gordini T15S, contesting several events including the 1953 RAC Tourist Trophy and the 1954 RAC Tourist Trophy. His co-driver in the Gordini was the Irish aviator Pearse Cahill. At the 1954 Wakefield Trophy at The Curragh he took an outright victory. He retired from racing around 1956, when business demands drew him fully back to Urney.
Gallagher became managing director of Urney in 1950, having gradually assumed control of production and sales through the 1940s. He drove the company's expansion into export markets — notably Britain, Canada, and the United States — at a time when Urney was being held up by the Irish government as a leading example of indigenous export enterprise. In 1958 he succeeded his father as company chairman while inviting Thomas Headon as equal partner and joint managing director; the company's workforce peaked at nearly 1,200 in the mid-1960s. In 1963, against his father's wishes, he and Headon sold the family's stake in Urney to the American conglomerate W. R. Grace. Gallagher continued as chairman for three more years but resigned after Headon's death in 1966. Urney declined through the 1970s under its foreign owners and the factory closed in 1981.
Beyond motor racing, Gallagher owned extensive farming and stud interests, including the 2,300-acre South Sloblands in County Wexford and the 335-acre Ballygoran stud in County Kildare. He owned racehorses, most notably Fiery Diplomat, who won races in France, England, and Ireland in 1972. He held directorships at Coras Trachtála and was appointed to the board of Irish Shipping in 1975. In 1977 he left Ireland with Máirín McGrath, a woman thirty-seven years his junior, and from 1980 the couple lived in Sagra, near Alicante, Spain, where he died on 31 October 2006.