Ted Dicks in 1954. He worked as a teacher before achieving success in the West End. Photograph: Adrian Bailey

The composer Ted Dicks, who has died aged 83, was best known for the comic songs Right, Said Fred and The Hole in the Ground. The producer George Martin, who commissioned them, praised both songs for their "clever lyrics and quirky melodies, which hung together so neatly, leaving plenty of space for us to create a sound picture. All we had to do was add the right sound effects and musical arrangements." Dicks also wrote television scripts and theme songs for films and television, including the cult children's series Catweazle (1970-71).

He was born in north London, the son of a postal worker, Fred Dicks, and his wife, Violet. He attended Hornsey School of Art before being called up for national service. Following his two years in the RAF, Dicks won a scholarship to the Royal College of Art. There, he made a lifelong friend in the future novelist Len Deighton and they put on entertainments together. Although his art took second place to his music, Dicks continued to paint throughout his life and sold many canvases.

In the mid-1950s, Dicks taught in a school and joined the amateur Mountview theatre club in north London, where he composed his first show, Let's Go Mad, renamed Look Who's Here! when it was given a short run in the West End in 1960. Dicks went on to write with Barry Cryer, including material for a show starring Danny La Rue. His breakthrough came when he joined forces with the actor and lyric writer Myles Rudge.

Dicks saw Rudge on stage in Julian Slade's Salad Days and the duo wrote the revue And Another Thing together in 1960. It featured Anna Quayle, Lionel and Joyce Blair and Bernard Cribbins. After touring the provinces, And Another Thing had a lengthy run at the Fortune theatre in London. Martin saw the show and decided to record Folk Song, a satirical number performed by Cribbins. It sold enough copies for Martin to commission more material for Cribbins from Dicks and Rudge. Both The Hole in the Ground and Right, Said Fred were top 10 hits in 1962. The latter, the tale of an impossible task for a trio of removal men, was inspired by the delivery of a piano to Dicks.

His and Rudge's only subsequent hit was A Windmill in Old Amsterdam for Ronnie Hilton in 1965, but their songs were also recorded by Topol, Jim Dale, Joan Sims, Petula Clark (The Happiest Christmas) and Val Doonican (the children's song Annabelle). In 1966, the Dicks-Rudge romantic ballad Other People was the B-side of Matt Monro's hit Born Free and brought the authors considerable royalties. In 1967, the duo created an album of songs for Kenneth Williams, On Pleasure Bent. Two years later, Dicks provided the music for new songs used in the TV series Cribbins. He also wrote film theme songs with the actor and producer Hazel Adair, for whom he had written scripts for the soap operas Compact and Crossroads.

His final collaboration with Rudge was a musical, Strip, about characters in a daily newspaper cartoon. It was commissioned for the Belgrade theatre, Coventry in the early 1970s, but never staged. Dicks had recently been revising the show.

He is survived by his wife, Liz, and his son, Adam.

• Edward Dicks, composer and writer, born 5 May 1928; died 27 January 2012