If $X=\mathrm{Spec}(A)$ is the spectrum of a domain $A$, with $\eta=(0)$ the generic point of $X$, then the equality $\mathscr{O}_{X,\eta}=A_{(0)}=\mathrm{Frac}(A)$ is built into the definition of the structure sheaf of $X$.
In general, for $X$ any scheme and $U\subseteq X$ an open subscheme, for any $x\in U$, the map $\mathscr{O}_{X,x}\rightarrow\mathscr{O}_{U,x}$ induced by the open immersion $U\hookrightarrow X$ is an isomorphism, so stalks can be ``computed" in any open subscheme. Now if $X$ is integral with generic point $\eta$ and $U=\mathrm{Spec}(A)$ is an affine open, then $\eta\in U$ and we have $\mathscr{O}_{X,\eta}=\mathscr{O}_{U,\eta}=\mathrm{Frac}(A)$. Elements of $\mathscr{O}_{X,\eta}$ are equivalence classes of pairs $(f,V)$, where $V\subseteq X$ is open and $f\in\mathscr{O}_X(V)$. In particular, any element $f\in A=\mathscr{O}_X(U)$ gives rise to the equivalence class of $(f,U)$ in $\mathscr{O}_{X,\eta}$, which is identified with the image of $f$ under the canonical injection $A\hookrightarrow\mathrm{Frac}(A)$ under the identification above. But there is no reason that an element of $\mathscr{O}_{X,\eta}$ should necessarily come from a global section of $X$.
Maybe you mean that an element of $\mathscr{O}_{X,\eta}$ should come from a global section of $U$, i.e., from an element of $A$? But you shouldn't expect this either, because the map $A\hookrightarrow\mathrm{Frac}(A)$ is not surjective unless $A$ is already a field.
For simplicitly let us assume that $\mathrm{Spec}(A)$ is integral (I'll leave you to think about the non-integral case) with unique generic point $\eta$. If $\{\eta\}$ is open then we know that there exists some neighborhood $D(f)$ of $\eta$ contained in $\{\eta\}$ and thus, of course, $D(f)=\{\eta\}$. From this, we see that
$$A[f^{-1}]=\mathcal{O}(D(f))=\mathcal{O}_{\mathrm{Spec}(A),\eta}=\mathrm{Frac}(A)$$
where the middle equality holds since there are no neighborhoodsof $\eta$ properly contained in $D(f)$.
Conversely, we see that if there exists some $f$ in $A$ such that $\displaystyle A[f^{-1}]=\mathrm{Frac}(A)$ then we see that, in particular, $A[f^{-1}]$ is a field and so $\mathrm{Spec}(A[f^{-1}])$ only consists of one point. But, the map $\mathrm{Spec}(A[f^{-1}])\to \mathrm{Spec}(A)$ is an open embedding with image $D(f)$ and so, in particular, its image contains $\eta$. But, since $D(f)$ consists of only one point we must have that $D(f)=\{\eta\}$ and thus $\{\eta\}$ is open.
Thus, from the above we deduce the following:
Proposition: Let $A$ be a domain. Then the (unique) generic point $\eta$ of $\mathrm{Spec}(A)$ is open if and only if there exists some $f$ in $A$ such that $A[f^{-1}]=\mathrm{Frac}(A)$.
Let us give some simple examples/non-examples:
Example 1: Let $\mathcal{O}$ be a DVR with uniformizer $\pi$. Then, $\mathrm{Frac}(\mathcal{O})=\mathcal{O}[\pi^{-1}]$ and so you see that the generic point of $\mathrm{Spec}(\mathcal{O})$ is open. In fact, $\mathrm{Spec}(\mathcal{O})$ consists, as is used very often, of an open generic point $\eta$ and a closed point $(\pi)$.
Remark 1: More generally, if $K$ is a field and $\mathcal{O}$ is a so-called microbial valuation ring in $K$ (e.g. see [1, §I.1.5]) then $K=\mathcal{O}[\varpi^{-1}]$ for any pseudo-uniformizer $\varpi$ (e.g. see [1, Lemma I.1.5.9]) and so the generic point of $\mathrm{Spec}(\mathcal{O})$ is open. Such valuation rings play a pivotal role in Huber's theory of adic spaces. As an example, one can consider the the valuation induced on $\mathrm{Frac}(\mathbb{C}_p\langle t\rangle)$ by the valuation
$$\left|\sum_{n=0}^\infty a_n t^n\right|=\sup |a_n|$$
on
$$\mathbb{C}_p\langle t\rangle:=\left\{\sum_{n=0}^\infty a_n t^n:\lim a_n=0\right\}$$
Then, the valuation ring in $\mathrm{Frac}(\mathbb{C}_p\langle t\rangle)$ is an example of a microbial valuation ring. You can make even more exotic (non-rank $1$) examples. See [1, §I.1.5] again).
Non-example 2: Certainly $\mathbb{Z}$ doesn't have open generic point since there is no element $f$ in $\mathbb{Z}$ such that $\mathbb{Z}[f^{-1}]=\mathbb{Q}$. Indeed, this is clear by thinking about the fact that $v_p(f)\ne 0$ for only finitely many $p$ (where $v_p$ is the $p$-adic valuation).
Example/Non-example 3: If $A$ is finite type over a field $k$ (and a domain) then the generic point of $\mathrm{Spec}(A)$ is open if and only if $A$ is a finite extension of $k$. Indeed, one easy way to see this is that this implies that there exists some $f$ in $A$ such that $A[f^{-1}]=\mathrm{Frac}(A)$. Since $\mathrm{Spec}(A[f^{-1}])\to \mathrm{Spec}(A)$ is an open embedding this implies (e.g. see [2, Theorem 5.22(3)]) that $\mathrm{Spec}(A)$ has dimension zero from where the conclusion follows (e.g. see [2, Corollary 5.21]).
Remark 2: Combining Example 1 and Example/Non-example 3 we are able to observe an interesting subtelty. Namely, as we used in the latter (and is well-known) if $X$ is an irreducible variety then $\dim(U)=\dim(X)$ for any open subset $U$ of $X$. This is false for general rings as Example 1 shows since $\dim\{\eta\}=0$ but $\dim \mathcal{O}=1$ (in the DVR case).
References:
[1] Morel, S., 2019. Adic Spaces. Lecture Notes. https://web.math.princeton.edu/~smorel/adic_notes.pdf.
[2] Görtz, U. and Wedhorn, T., 2010. Algebraic geometry. Wiesbaden: Vieweg+ Teubner.
Best Answer
Let me compile the discussion from the comments to mark this as answered.
If $X$ is a topological space, $x\in X$, $U\subset X$ an open subset containing $x$, and $\mathcal{F}$ a sheaf on $X$, then the stalk of $\mathcal{F}$ at $x$ is the same as the stalk of $\mathcal{F}|_U$ at $x$. Using your definition of the stalk as equivalence classes that agree on an open neighborhood of $x$, we can prove this by restricting a representative $(f,V)$ to $(f|_U,V\cap U)$. (With other definitions, there are other proofs - categorically, open neighborhoods of $x$ inside $U$ form a cofinal subset of the open neighborhoods of $x$, which means that calculating the limit along them gives the same value.)
Next, the generic point of $X$ is the generic point of the affine open subscheme $\operatorname{Spec} A\subset X$ as well (exercise: prove this, perhaps by assuming it's not and seeing what contradiction you can get, like disjoint open subsets or a decomposition of $X$ as a union of two proper closed subsets). Since $(0)$ is the generic point of $\operatorname{Spec} A$, we have that $\mathcal{O}_{X,\xi} \cong \mathcal{O}_{\operatorname{Spec} A, (0)} \cong A_{(0)} \cong K(A)$.