(Assuming that $f$ and $g$ are themselves positive valued functions), your idea is sort of right, but sort of wrong. You are trying to maximize $f-g$, so this involves making $g$ small and making $f$ big, but it's misleading to say you want to maximize $f(x)$ and minimize $g(x)$ because there may be some tradeoff between the two. What you want to do is exactly what you wrote mathematically: to maximize the difference.
You can imagine that $f$ is revenue, and $g$ is cost, for example, when a company makes $x$ products. If their maximum profit is attained by making 30,000 products, this doesn't mean that $g(x)$ is minimized at 30,000. Clearly it would cost less to make just $25,000$ products, but the point is that the extra revenue from making $30,000$ outweighs this cost. There is a trade-off between $f$ and $g$. Thus you want to maximize exactly what you wrote down, $f(x) - g(x)$, i.e. the company's profit function.