How do I convert true heading to magnetic heading or the other way around?
Short answer: Yes there is, but it doesn't always work, it involves a LOT of math, and you're probably not gonna like it.

Medium Answer: Most flight planning software incorporates a True/Magnetic heading conversion system (ForeFlight for example).
Using an electronic flight planning tool like this is probably your best bet if you want an on-the-fly determination made for you.

Long answer:
International Association of Geomagnetism and Aeronomy (now there's a mouthful!) periodically publishes what's known as &quot;International Geomagnetic Reference Field (IGRF)&quot;.  It's a mathematical model of Earth's geomagnetic field, which you can work from some exceptionally complicated trigonometry (or just look up the coefficients in a table which is what most sane folks do).
If reading text like &quot;Mathematically, the IGRF model consists of the Gauss coefficients which define a spherical harmonic expansion of the magnetic scalar potential.&quot; makes your eyes roll back into your head (I was a math nerd and it makes MINE roll back!) using the model is probably not for you.
If your eyes are still focused on this text however, click on through to that link way back at the top of my answer and you'll be rewarded with a formula you can plug into your trusty calculator.