We present a method to calculate the derivative of a functional that depends on the shape of a body immersed in an acoustic media. The functional depends implicitly on the shape through the solution of an exterior acoustic problem. The derivative is calculated in terms of the solution of the primal problem and an auxiliary problem, the adjoint problem. An important aspect of this method is that the cost of calculating the derivative is independent of the number of parameters used to represent the shape of the body. This allows for efficient solution of optimization problems in structural acoustics.