When to use callbacks?

I don't quite understand the use of callbacks in node.js. I understand that if you have something like

result = db.execute(query);
doSomething(result);

you should make doSomething a callback because doSomething would get executed before the result is ready. This makes sense because the db operation can be expensive.

Now let's say I have something like

result = calculate(x,y)
doSomething(result)

where calculate is not expensive (i.e. no reading from database or I/O), should I still be using a callback? How can I tell if my function would complete before or after the next line would get executed?

Thanks

In short, your function needs to accept a callback parameter if your function is calling asynchronous functions (e.g. invoking I/O operations or database calls) so that the results of those calls can be provided to the caller of your function. If your function is just making synchronous calls then your function is also synchronous and you don't need a callback parameter (as in the case of your second example).