Energy of magnetostatic field When we want to calculate electrostatic energy of a system we use the fact that the energy of interaction of 2 point charges is $kq_1q_2/r$. Now I'm interested if there is an analogous formula for magnetostatic energy of 2 small current components, considering that there is an analogous for Coulomb's law(Biot-Savart's law).
 A: Sort of.  But it's not as useful of a quantity as the electrostatic potential energy.
It can be shown (see, e.g., Chapter 7 of Griffiths' Introduction to Electrodynamics) that the potential energy stored when we create an isolated current distribution $\vec{J}$ is
$$
U_B = \frac{1}{2} \int \vec{J}(\vec{r}) \cdot \vec{A}(\vec{r}) \,d^3 \vec{r},
$$
where $\vec{A}$ is the resulting vector potential.  But the vector potential, in Coulomb gauge ($\vec{\nabla} \cdot \vec{A} = 0$) satisfies
$$
\vec{A}(\vec{r}) = \frac{\mu_0}{4 \pi} \int \frac{\vec{J}(\vec{r}')}{|\vec{r} - \vec{r}'|} d^3 \vec{r}'
$$
and so we can write the potential energy as a double volume integral:
$$
U_B = \frac{\mu_0}{8 \pi} \iint \frac{\vec{J}(\vec{r}) \cdot \vec{J}(\vec{r}')}{|\vec{r} - \vec{r}'|} \,d^3 \vec{r}\,d^3 \vec{r}'.
$$
If we compare this to the corresponding expression for the electrostatic case,
$$
U_E = \frac{1}{2} \int \rho(\vec{r}) V(\vec{r}) \, d^3\vec{r} = \frac{1}{8 \pi \epsilon_0} \iint \frac{\rho(\vec{r})  \rho(\vec{r}')}{|\vec{r} - \vec{r}'|} \,d^3 \vec{r}\,d^3 \vec{r}',
$$
we can see that both of these expressions involve a double integral over the source, and that the analog of $q_1 q_2/(4 \pi \epsilon_0 r)$ in the electrostatic case should be something like
$$
\frac{\mu_0}{4 \pi}  \frac{\vec{J}_1 \cdot \vec{J}_2}{r}
$$
for the magnetic case.
That's all well and good, but it's tricky to interpret.  For example, we know that in the electric case, two isolated charges will repel;  and we can see from the form of the potential energy that decreasing $r$ will increase $U_E$.  But in the magnetic case, our potential energy $U_B$ for two aligned current elements also increases as $r$ decreases, and we know that two aligned currents should attract each other (i.e, we would expect it to decrease.)  So this energy does not seem to have some of the properties we expect it to.
The reason for this is that the derivation of the above potential energy is for the creation of an isolated current distribution;  but if we're trying to figure out the interaction energy of two fixed current distributions, then moving one will cause inductive effects in the other.  If we are assuming that the currents are fixed, this means that our power supply will have to spend energy keeping the currents fixed, and the $U_B$ quantity doesn't take this energy into account.  This distinction doesn't arise in the electric case:  moving one charge won't change the amount of charge on another object, but moving one current can change the amount of current in another object.
It is possible to construct out an interaction energy density for configurations of current loops, with the property that this energy decreases when two attracting current distributions move closer to each other;  in fact, it actually turns out to be numerically equal to $U_B$ but with the sign reversed.  For details on this construction, I recommend Zangwill's Modern Electrodynamics, Chapter 12.
