In modern hearing aids, Hearing Loss Compensation (HLC) is implemented by dynamic range compression circuits. Although this approach provides reasonable results, it is unable to computationally link the compensation algorithm to the hearing loss problem. In this paper, we propose a data-driven approach that describes HLC as a probabilistic inference problem and automatically infers the solution using message passing on a factor graph. We show that using this approach we can not only derive an unique solution for a specified hearing loss model, but we can also solve the parameter estimation (a.k.a. fitting) as demonstrated by a simulation example. The proposed approach allows straightforward substitution by alternative hearing loss models, and can be applied to other signal processing applications.