When given choices on (for example) an investment action to make, the opportunity cost represents the potential loss of taking one action versus another.
Let’s say you have the choice of buying stock A or a U.S. Treasury yielding 4%, and you choose stock A. But it turns out that stock A only ends up producing a 1% return on the year. In this case, your opportunity cost for that year would have been 3%.