For more context, in case this is necessary, let $\phi:R \to T$ be a morphism of rings. Let $(X, O_X) = (Spec(R), O_{Spec(R)})$ and let $(Y, O_Y) = (Spec(T), O_{Spec(T)})$ be the corresponding affine schemes.
Assume it has been established that for every $O_Y$ module $G$ there exists an isomorphism:
$$Hom_{Mod(Y)}(f^*(O_X), G) \cong Hom_{Mod(Y)}(O_Y, G)$$
for $f^* := Spec(\phi)^*$ the pullback of the continuous map $Spec(\phi):Y\to X$.
Why, then, could we conclude that $f^*(O_X)\cong O_Y$? This has been stated as part of a proof in my Schemes course, but I have not yet been able to figure out the reasoning, exactly.
It follows from the Yoneda lemma that for any objects $A$ and $B$ in a category $\mathcal{C}$ the following are equivalent:
Indeed, the image of an isomorphism $A\cong B$ under either of the Yoneda embeddings $A\mapsto \text{Hom}_{\mathcal{C}}(A,-)$ or $A\mapsto \text{Hom}_{\mathcal{C}}(-,A)$ will be an isomorphism (by functoriality). And both Yoneda embeddings are fully faithful, so any isomorphism between the Hom-functors will have a preimage which is an isomorphism $A\cong B$.
It is a very common strategy in category theory to understand the isomorphism type of an object by understanding either the maps into it or the maps out of it.
You can apply this in your case to establish that $f^*(O_X)\cong O_Y$, but you'll need more than the existence of the isomorphism you stated, for each $G$. You also need to show naturality in $G$, i.e. that these isomorphisms cohere to a natural isomorphism of functors $$\text{Hom}_{\text{Mod}(Y)}(f^*(O_X),-)\cong \text{Hom}_{\text{Mod}(Y)}(O_Y,-).$$
These kinds of naturality checks are almost always omitted from proofs, because they're usually straightforward. But when you're first getting used to Yoneda arguments, I think it's really important to work out the details yourself!