INSERT .. ON CONFLICT DO UPDATE SET error
The excluded record needs to reference columns from the target table, not the source (e.g. a VALUES clause would not have any column names anyway).
It's also good coding practice to always specify the target columns in the INSERT statement.
INSERT INTO the_table (id, first_seen, last_seen, duration)
SELECT ID_tmp, First_seen_tmp, Last_seen_tmp, Duration_tmp
FROM tmp_table
ON CONFLICT (ID)
DO UPDATE 
   SET last_seen = EXCLUDED.last_seen,
       duration = EXCLUDED.last_seen - the_table.first_seen;