Define a sequence $(a_n)$ by $a_1 =1, a_2 =2,$ and $a_{k+2}=2a_{k+1}+a_k$ for all positive integers $k$. Determine all real numbers $\beta >0$ which satisfy the following conditions:

(A) There are infinitely pairs of positive integers $(p,q)$ such that $\left| \frac{p}{q}- \sqrt{2} \, \right| < \frac{\beta}{q^2 }.$

(B) There are only finitely many pairs of positive integers $(p,q)$ with $\left| \frac{p}{q}- \sqrt{2} \,\right| < \frac{\beta}{q^2 }$ for which there is no index $k$ with $q=a_k.$
1. **Understanding the Sequence and Pell's Equation:**
   The sequence \((a_n)\) is defined by:
   \[
   a_1 = 1, \quad a_2 = 2, \quad a_{k+2} = 2a_{k+1} + a_k \quad \text{for all positive integers } k.
   \]
   This sequence corresponds to the solutions \(q\) of the Pell equation \(p^2 - 2q^2 = \pm 1\).

2. **Condition (A):**
   We need to find \(\beta > 0\) such that there are infinitely many pairs \((p, q)\) with:
   \[
   \left| \frac{p}{q} - \sqrt{2} \right| < \frac{\beta}{q^2}.
   \]
   For the solutions of \(p^2 - 2q^2 = 1\), we have:
   \[
   |p - \sqrt{2}q| = \frac{1}{p + \sqrt{2}q}.
   \]
   Since \(p \approx \sqrt{2}q\), we get:
   \[
   |p - \sqrt{2}q| < \frac{1}{2\sqrt{2}q}.
   \]
   Therefore:
   \[
   \left| \frac{p}{q} - \sqrt{2} \right| < \frac{1}{2\sqrt{2}q^2}.
   \]
   Hence, condition (A) is satisfied when:
   \[
   \beta \ge \frac{1}{2\sqrt{2}}.
   \]

3. **Condition (B):**
   We need to find \(\beta > 0\) such that there are only finitely many pairs \((p, q)\) with:
   \[
   \left| \frac{p}{q} - \sqrt{2} \right| < \frac{\beta}{q^2},
   \]
   for which there is no index \(k\) with \(q = a_k\).

   For arbitrary \((p, q)\), we have:
   \[
   |p^2 - 2q^2| \ge 1.
   \]
   Thus:
   \[
   \left| \frac{p}{q} - \sqrt{2} \right| \ge \frac{1}{q(p + q\sqrt{2})}.
   \]
   Therefore, there are only finitely many solutions \((p, q)\) when:
   \[
   \beta < \frac{1}{2\sqrt{2}}.
   \]

   For each \(q\) not in the sequence, we have:
   \[
   |p^2 - 2q^2| \ge 2.
   \]
   Thus:
   \[
   \left| \frac{p}{q} - \sqrt{2} \right| \ge \frac{2}{q(p + q\sqrt{2})}.
   \]
   Therefore, there are only finitely many such solutions \((p, q)\) when:
   \[
   \beta < \frac{1}{\sqrt{2}}.
   \]

   The inhomogeneous Pell equation \(p^2 - 2q^2 = 2\) has infinitely many solutions (not in the sequence), and for these:
   \[
   |p - \sqrt{2}q| = \frac{2}{p + \sqrt{2}q} < \frac{1}{\sqrt{2}q}.
   \]
   Hence, there are infinitely many solutions (not in the sequence) for:
   \[
   \beta \ge \frac{1}{\sqrt{2}}.
   \]

4. **Combining Conditions (A) and (B):**
   Condition (A) is satisfied if:
   \[
   \beta \ge \frac{1}{2\sqrt{2}}.
   \]
   Condition (B) is satisfied if:
   \[
   \beta < \frac{1}{\sqrt{2}}.
   \]
   Therefore, the combined condition is:
   \[
   \frac{1}{2\sqrt{2}} \le \beta < \frac{1}{\sqrt{2}}.
   \]

The final answer is \( \boxed{ \frac{1}{2\sqrt{2}} \le \beta < \frac{1}{\sqrt{2}} } \).