The answer is 'not always'.  Here is a simple case where you cannot recover the connection up to gauge transformation from the curvature:  Let $n=2$, let the rank of $E$ be $m$, and, since $E$ is trivial over $B^2(0)$, we might as well take it to be $E = B^2(0)\times\mathbb{R}^m$, i.e., trivialized.  Then $F$ is just a $2$-form with values in $\mathfrak{so}(m)$, and a connection $\alpha$ is a $1$-form on $B^2(0)$ with values in $\mathfrak{so}(m)$.  If $F$ is the curvature of $\alpha$, we have $\mathrm{d}\alpha+\alpha\wedge\alpha = F$.  If $F = f\,\mathrm{d}x^1\wedge\mathrm{d}x^2$ and $\alpha = a_1\,\mathrm{d}x^1+a_2\,\mathrm{d}x^2$, then this becomes the simple partial differential equation
$$
\frac{\partial a_2}{\partial x^1}-\frac{\partial a_1}{\partial x^2}
+[a_1,a_2] = f.
$$
If you specify $a_1$ (for example), this becomes a linear first order partial differential equation for $a_2$, so there are many solutions, no matter what $F$ is.  Essentially, you get to choose an arbitrary function $a_1$ on $B^2(0)$ with values in $\mathfrak{so}(m)$ and then you get to choose $a_2(0,x^2)$ arbitrarily.  So $F$ certainly does not determine $\alpha$.

Well, what about up to gauge transformation? Suppose that $\beta$ be another connection with curvature $F$.  Then $\mathrm{d}\beta+\beta\wedge\beta = F$.  If $\beta$ were gauge equivalent to $\alpha$, then there would exist a map $g:B^2(0)\to\mathrm{SO}(m)$ such that $\beta = g^{-1}\mathrm{d}g + g^{-1}\alpha g$.  This would imply that $F = g^{-1}Fg$, so $f = g^{-1} f g$.  

If $f\equiv0$, this is no condition, but if $f$ is 'generic' in the sense that, at each point $p\in B^2(0)$, the centralizer of $f(p)\in\mathfrak{so}(m)$ is a maximal torus in $\mathrm{SO}(m)$, then $g(p)$ would have to take values in that maximal torus.  When $m>2$, a maximal torus is a proper subgroup of $\mathrm{SO}(m)$, so the only possible gauge transformations that could work would be very restricted, too restricted to be able to account for the arbitrariness in $\alpha$.

To fix ideas, take $m=3$ and assume that $f\equiv f(0)$ is a nonzero constant function on $B^2(0)$.  Then $\beta$ could be gauge equivalent to $\alpha$ only if the gauging function $g$ took values in the maximal torus (a circle) consisting of the elements of $\mathrm{SO}(3)$ that commute with $f(0)$.  That forces $g$ to take values in a circle, so it depends on only one function of two variables, but $\alpha$ depends on three functions of two variables, so the vast majority of the solutions to $\mathrm{d}\alpha + \alpha\wedge\alpha = F$ will not be gauge equivalent.

In fact, in this explicit example, it's easy to see that one can find such a solution $\alpha$ that has holonomy in the maximal torus and one can also find solution $\alpha$ whose holonomy is all of $\mathrm{SO}(3)$.

Meanwhile in dimensions $n >3$, for the generic $F$, the equation $\mathrm{d}\alpha + \alpha\wedge\alpha = F$ will completely determine $\alpha$ algebraically by the Bianchi identity $\mathrm{d}F = F\wedge\alpha-\alpha\wedge F$, so a 'generic' curvature determines the connection $\alpha$, and not just up to gauge equivalence.