How to know the difference between dial and forward

When a call is dialed it goes to the same place in the dialplan as the call dialed from the forward command on the phone . How to know the difference ?

What the forward button on the phone does is determined by the phone. At the very least you need to identify the phone. Ideally you need to say what the button does at the protocol level.

Anticipating some possibilities: the enquiry phase of a SIP attended transfer is indistinguishable from an outgoing call. For at least some cases where Asterisk can identify a transfer (features.conf ones, and just maybe some blind ones) there is a channel variable that overrides the context used.