Asymptotic notation arose in number theory, and is now commonly used in combinatorics. It has nothing to do with algorithms per se. We use asymptotic notation to describe the resource consumption of algorithms, mainly time and space. It comes in five main flavors:
- $f(n) = O(g(n))$ if $f(n) \leq Cg(n)$ for some constant $C>0$. In words, $f(n)$ grows at most as fast as $g(n)$.
- $f(n) = \Omega(g(n))$ if $f(n) \geq cg(n)$ for some constant $c>0$. In words, $f(n)$ grows at least as fast as $g(n)$.
- $f(n) = \Theta(g(n))$ if $cg(n) \leq f(n) \leq Cg(n)$ for some constants $C,c>0$. In words, $f(n)$ and $g(n)$ grow at the same rate.
- $f(n) = o(g(n))$ if $\lim_{n\to\infty} f(n)/g(n) = 0$. In words, $f(n)$ grows slower than $g(n)$.
- $f(n) = \omega(g(n))$ if $\lim_{n\to\infty} f(n)/g(n) = \infty$. In words, $f(n)$ grows faster than $g(n)$.
When we say that an algorithm runs in time $O(f(n))$, we mean that its running time is bounded by $Cf(n)$, for some constant $C > 0$. Often there is an unstated assumption that the bound is tight, that is, the function $f(n)$ cannot be replaced by any asymptotically smaller function. However, strictly speaking, this is not the meaning of $O(f(n))$. For example, quicksort runs in time $O(n!)$. This is a pretty bad bound, but the statement is mathematically valid nonetheless.
What do we mean when we say that an algorithm runs in time $\Theta(f(n))$? Strictly speaking, this means that the running time of the algorithm is always between $cf(n)$ and $Cf(n)$, for some constants $C,c>0$. However, sometimes this kind of bound is too much to hope for, since the running time could depend on the particular input, or if the algorithm is randomized, on the random coin tosses. For example, quicksort always runs in $O(n^2)$, but sometimes it runs in $O(n\log n)$. We can say that its worst-case complexity is $\Theta(n^2)$, but it is not true that its runtime is $\Theta(n^2)$.
When should you use which notation? That's up to you. If you can bound the quantity in question tightly, then you might as well use big Theta. If all you have is an upper bound, you should use big O. If you know the worst-case complexity but want to describe the "every-case" complexity, the convention is to use big O, with the tacit understanding that the bound is probably tight for the worst case.