As mentioned in the comments, it depends. Different movies have different amounts of artistic authority granted to the director. For any big name director working on a big budget film, the director usually makes the choice with oversight and final approval by the producers.
For a big budget but lesser known director, the producers are more likely to exert control, potentially going as far as to decide who the composer will be whether the director likes it or not. If it’s a big break for a relatively unknown director, they are more likely to go along with whatever the producers want so they don’t get kicked off the film.
On the other end of the spectrum, an independent film by an auteur with small budget, there is usually a closer relationship between all the principles of the film, so the producer(s) and director may be of like mind when it comes to music, and/or they might personally know someone who they want to handle the music for the film.
And let’s not forget the occasional example (John Carpenter) where the director is the composer!