It depends on the homology class of the knot, and also on the framing, which in your terminology is the choice of longitude. For knots in the 3-sphere (or more generally in a homology 3-sphere), there is a well-defined 0-framing, and that gives the longitude. So in general, you should ask about surgery on a knot with a given framing. A correct statement might be that if you have two homologous knots, $K_0$ and $K_1$, then there is a correspondence between their framings; moreover surgery on $K_0$ and $K_1$ with corresponding framings gives manifolds with the same homology.
If you want to figure out how the homology changes, then you'll find that the dependence on the homology class is maybe a little subtle, although it is an excellent exercise to figure out what is going on. For instance, surgery on a null-homologous knot with an appropriate framing will increase the first Betti number, but surgery on a knot carrying a homology class of infinite order will decrease $b_1$. For knots whose homology class is torsion in $H_1(M)$, the rational-valued self-linking plays a crucial role.
You might find it useful to look at the early papers on surgery theory, eg section 5 of Kervaire-Milnor, Groups of homotopy spheres. I. Ann. of Math. (2) {\bf 77} 1963 504–537. The paper of Wall, Killing the middle homotopy groups of odd dimensional manifolds. Trans. Amer. Math. Soc. 103 1962 421–433, is perhaps even more useful, because it explains the role of the self-linking form more explicitly.