I have posted a proof below, and would appreciate it if someone could review it for accuracy. Thanks!
Problem:
Let n $\in$ $\mathbb{Z}$ with $n$ $\ge$ 3. Prove the following:
(a) Z(D$_{2n}$) = 1 if $n$ is odd.
(b) Z(D$_{2n}$) = {1, r$^k$} if $n$ = $2k$.
Note that $r$ and $s$ generate D$_{2n}$ with the group presentation { $r$,$s$ | $r$$^n$ = $s$$^2$ = 1, $rs$ = $sr$$^{-1}$ }
Proof:
part (a)
Let $n$ $\ge$ 3 where $n$ $\in$ $\mathbb{Z}$ and $n$ is odd.
For any x $\in$ Z(D$_{2n}$), x must commute with both $s$ and $r$, since both are in $D_{2n}$. Note that if $x$ commutes with both $s$ an $r$, then $x$ commutes with any element of $D_{2n}$ since $r$ and $s$ generate D$_{2n}$.
Then for any x$\in$ Z(D$_{2n}$), we have $xr$ = $rx$, where x is of the form $x$ = s$^j$r$^w$ (any such element can be arranged into this form via the relation $rs$ = $sr$$^{-1}$ and the fact that $r$ and $s$ generate D$_{2n}$). Note that since r and s have finite order, the exponents are modulo n and modulo 2 for $r$ and $s$ respectively.
Then we have s$^j$r$^w$$r$ = $r$s$^j$r$^w$. Which implies s$^j$r$^{w+1}$ = s$^j$r$^{w +- 1}$
In the case where the power of r on the RHS is $w$ - 1, it is clear we cannot have equality unless |r| = 1, which it is not. Note that if $j$ is even then we have only the $w$ + 1 case. Hence $x$ may be of the form $1$$r$$^w$ = $r$$^w$.
Also we have that x must commute with $s$, hence $s$$x$ = $x$$s$.
Then $s$$r$$^w$ = $r$$^w$$s$. Which implies $s$$r$$^w$ = $s$$r$$^{-w}$.
Applying s$^{-1}$ to both sides we arrive at the task of finding when r$^w$ = r$^{-w}$ i.e when $w$ = $-w$. But since r has finite order we have:
$$ \bar{w} = (n-1)*w $$
where $\bar{w}$ is the residue class of w modulo n. Hence for some a $\in$ $\mathbb{Z}$$_+$
$$ w + an = wn - w $$ $$ 2w = wn - an $$ $$ 2w = n(w-a) $$
Now since 0 $\lt$ w $\le$ n we have that the LHS is greater than 0. Also since n $\ge$ w then (w-a) $\le$ 2, since otherwise the RHS would be greater than the LHS. So since n is odd we must have that (w-a) is even and hence (w-a) = 2, implying that 2w = 2n and hence n = w.
Hence x = $r$$^w$ = $r$$^n$ = 1. So Z(D$_{2n}$) = 1.
part (b)
From the argument above any x $\in$ Z(D$_{2n}$) must be of the form $s$$^j$$r$$^w$ for j even and j $\in$ $\mathbb{Z}$. Then x is of the form $r$$^w$ for $0$ $\lt$ w $\le$ $n$. Since $n$ is even we have the equation below is satisfied when $2w$ = $n$ or $w$ = $n$, since (w-a) $\le$ 2 but also (w-a) $\ge$ 0 for (w-a) $\in$ $\mathbb{Z}$$_+$.
$$ 2w = n(w - a) $$
Hence $r$$^w$ $\in$ Z(D$_{2n}$) when $2w$ = $n$, as desired.