In inverse geophysical resistivity problems, it is common to optimize for specific resistivity values and bed boundary positions, as needed, for example, in geosteering applications. When using gradient-based inversion methods such as Gauss-Newton, we need to estimate the derivatives of the recorded measurements with respect to the inversion parameters. In this article, we describe an adjointbased formulation for computing the derivatives of the electromagnetic fields with respect to the bed boundary positions. The key idea to obtain this adjoint-based formulation is to separate the tangential and normal components of the field, and treat them differently. We then apply this method to a 1.5D borehole resistivity problem. We illustrate its accuracy and some of its convergence properties via numerical experimentation by comparing the results obtained with our proposed adjoint-based method vs. both the analytical results when available and a finite differences approximation of the derivative.