At first we need to determine the sample space.
The sample space is analogous to a 'n' digit number whose each place can have only two digits, i.e., either a head(H) or a tail(T). For example, a three digit number can be written as HTT, or, HTH, or, HHH, etc.
Considering this analogy, we get the total number of 'n' digit numbers as $2^5$. Please refer to the figure: Sample space. So, our sample space consists of $2^5$ elements.
Now, we need the number of favorable events, which is in this case, odd number of heads. Therefore the number of favorable events is the summation of the series -
number of times we get only 1 head + number of times we get 3 heads + number of times we get 5 heads + number of times we get 7 heads + $\cdots$
Let the desired number of head be 3 and the coin is tossed eight times. So, one of our possible number is HHHTTTTT. The number of distinct permutations of this number is $\frac{8!}{3! \times 5!}$, which is equal to $8C_3$.
Generalizing this case, when the coin is tossed n number of times and for 'k' number of desired heads, the number of outcomes is $nC_k$.
So, finally we get the number of favorable events as $nC_1+nC_3+nC_5+nC_7+\cdots$
Now, we can determine the probability of getting odd number of heads as
\begin{align}
\text{P(odd numbers of heads)} &= \frac{nC_1+nC_3+nC_5+nC_7+\cdots}{2^n} \\
&= \frac{2^{n-1}}{2^n} \\ &= \frac{1}{2}
\end{align}