Finding $A$ such that $\nabla \times A = B$ for given $B$. Let $U = \mathbb{R}^3 \setminus \{(0,0,z) : z \in \mathbb{R}\}$ and let $B : U \rightarrow \mathbb{R}^3$ be a $C^\infty$ vector field defined by 
$$B(x,y,z)=\frac1{\rho^l} (-y,x,0)$$
where $\rho = \sqrt{x^2+y^2}$ and $l \in \mathbb{N}$. How can I find a vector field $A$ such that $\nabla \times A = B$?
The vector field $A$ surely exists, since $\nabla \cdot B = 0$. Is there a way to obtain such $A$?
 A: First:

The vector field $A$ surely exists, since $\nabla\cdot B = 0$.

This is not generally true. While $\nabla\cdot B = 0$ is a necessary condition for $A$ to exist, it is not sufficient in and of itself. The domain on which you are trying to invert the curl has to be sufficiently nice, topologically speaking. 
In your case, however, you can solve the problem by inspection. 
Recall that 
$$ \nabla \times A = ( \partial_y A_z - \partial_z A_y, \partial_z A_x - \partial_x A_z, \partial_x A_y - \partial_y A_x) $$
So in your case you can take $A_x = A_y = 0$ as an ansatz (a fancy way to say "a guess"), which would require that 
$$ \partial_y A_z = - y \rho^{-l} \qquad \partial_x A_z = - x \rho^{-l} $$
and which you observe can be found by taking 
$$ A_z = \frac{1}{l - 2} \rho^{2-l} $$
when $l \neq 2$ and 
$$ A_z = - \ln \rho $$
when $l = 2$. 
The solution, of course, is not unique: if you take $\phi$ any function then $\nabla\times \nabla \phi = 0$. So you to the $A$ found above you can add $\nabla \phi$ for any $\phi$ and still have a solution. 
