It isn't to do with the position in the sentence. The two words have different meanings.
'When' indicates a specific time.
By contrast, 'whenever' means 'any time' or 'it doesn't matter what time' or 'whatever time is convenient'.
For example, you would say 'Come to our house whenever you want. You're welcome any time.'
'Ever' is like 'any' - it suggests that all the options are possible. Similar words are 'whoever', whatever, and 'however'. They can sometimes be translated into French as " n'importe'. So 'whenever' can, in some cases, be translated as 'n'importe quand'