We propose a new deformation of the quantum harmonic oscillator Heisenberg–Weyl algebra with a parameter \(a>-1\). This parameter is introduced through the replacement of the homogeneous mass \(m_0\) in the definition of the momentum operator \(\hat{p}_x\) as well as in the creation–annihilation operators \({\hat{a}}^\pm\) with a mass varying with position x. The realization of such a deformation is shown through the exact solution of the corresponding Schrödinger equation for the non-relativistic quantum harmonic oscillator within the canonical approach. The obtained analytical expression of the energy spectrum consists of an infinite number of equidistant levels, whereas the wavefunctions of the stationary states of the problem under construction are expressed through the Hermite polynomials. Then, the Heisenberg–Weyl algebra deformation is generalized to the case of the Lie superalgebra \(\mathfrak {osp}\left( {1|2} \right)\). It is shown that the realization of such a generalized superalgebra can be performed for the parabose quantum harmonic oscillator problem, the mass of which possesses a behavior completely overlapping with the position-dependent mass of the canonically deformed harmonic oscillator problem. This problem is solved exactly for both even and odd stationary states. It is shown that the energy spectrum of the deformed parabose oscillator is still equidistant; however, both even- and odd-state wavefunctions are now expressed through the Laguerre polynomials. Some basic limit relations recovering the canonical harmonic oscillator with constant mass are also discussed briefly.