In these notes (p. 190), it is claimed that (possibly with superfluous hypotheses):
Claim. Let $M$ be a closed connected oriented smooth 4-manifold and let $c\colon S^1\hookrightarrow M$ be an embedding representing a non-trivial homology class. Then performing a surgery on $c$ does not affect $H_2(M)/\mathrm{Tors}$ nor the intersection form $q_M$.
Precisely, we are looking for an isomorphism $H_2(M)/\mathrm{Tors}\cong H_2(M')/\mathrm{Tors}$ such that $q_M\cong q_M'$. By surgery, I mean that one finds a tubular neightborhood $N\cong S^1\times D^3$ of $c$ in $M$ and construct a new smooth manifold $M'=(M\setminus N)\cup_{\partial N} (D^2\times S^2)$.
How does one show that? I can only show that such an isomorphism exists, but not that it preserves the intersection form (see below).
Partial proof. Denote respectively by $b_i$ and $b_i'$ the $i$-Betti number of $M$ and $M'$. Since $H_2(M)/\mathrm{Tors}$ is a free abelian group of rank $b_2$, it suffices to show that $b_2=b_2'$. Using Van Kampen's theorem, we find that $$ \pi_1(M)\cong\pi_1(M\setminus N)*_\mathbb{Z}\mathbb{Z}\cong\pi_1(M\setminus N) $$
and $$ \pi_1(M)\cong\pi_1(M\setminus N)*_\mathbb{Z}0\cong\pi_1(M\setminus N)/[c], $$
where $[c]$ is the image of $c$ in $\pi_1$. Using that $c$ represents a non-trivial homology class, we deduce that $b_1'=b_1-1$. By Poincaré duality, we also have that $b_3'=b_3-1$.
On the other hand, we compute that $\chi(M)=\chi(M\setminus N)+\chi(N)-\chi(\partial N)$ and $\chi(M')=\chi(M\setminus N)+\chi(D^2\times S^2)-\chi(\partial N)$, where $\chi(N)=\chi(S^1)=0$ and $\chi(D^2\times S^2)=\chi(S^2)=2$. It follows that $\chi(M')=\chi(M)+2$.
$M$ and $M'$ being closed connected manifold, we have $b_0=b_0'=b_4=b_4'=1$. With all of the above, we find that $b_2=b_2'$.
This answer ellaborates on @Cheerful_Parsnip's comment.
We can find surfaces $\Sigma_1,\ldots,\Sigma_{b_2}$ such that their homology classes $[\Sigma_i]$ define a basis of $H_2(M)/\mathrm{Tors}$. In that case, the intersection form is the matrix $\left((\Sigma_i\cdot\Sigma_j)\right)_{ij}$, where $(\Sigma_i\cdot\Sigma_j)$ is the algebraic intersection of $\Sigma_i$ and $\Sigma_j$. Moreover, the $\Sigma_i$'s generically do not intersect $c$ (by comparing dimensions), and we may assume they do not intersect $N$. After surgery, the $\Sigma_i$'s are untouched, and still have the same algebraic intersections.
To conclude, it remains to check that the classes $[\Sigma_i]$'s still define a basis of $H_2(M')/\mathrm{Tors}$. On one hand, since the intersection form is unimodular and in particular has a non-zero determinant, the family $[\Sigma_i]$'s remains free in $H_2(M')/\mathrm{Tors}$. On the other hand, as we showed already $b_2=b_2'$, this family must also be generating. This concludes.
Additional comment: we answer why the class of $\{p\}\times S^2$, for $p\in D^2$, is zero in $M'$ (asked in the comments, ellaborating on @Lee Mosher's answer). First, we may isotope $\{p\}\times S^2$ and assume $p\in c$. Then, recall that the Poincaré dual of $c$ can be represented as a 3-submanifold $Y\subset M$ such that $Y\cap N=\{p\}\times D^3$. Finally, we consider $Y\setminus N$ as a submanifold of $M'$ and check that $\partial(Y\setminus N)\cong\{p\}\times S^2$.