Where are you calling xTaskCallApplicationTaskHook() from, and which port are you using?
If you are calling it from traceTASKSWITCHED
OUT() then some (older) ports might call it on each tick, whereas newer ports should only call it when a context switch is actually required. The way to tell would be to look at how xTaskIncrementTick() is called in the port layer. If the return value of xTaskIncrementTick() is used to determine if vTaskSwitchContext() is called then it should traceTASKSWITCHED
OUT() should not be called on each tick, if the return value is ignored then it probably will be called on each tick.
If you are using traceTASKSWITCHED
OUT() then you can update your macro definition as follows:
static TaskHandle_t xLastTaskHandle = NULL;
if( pxCurrentTCB != xLastTaskHandle )
/* The task changed - run your code here. */
xLastTaskHandle = pxCurrentTCB;