There are a bunch of possible locations.
If you went server side code options are
* /skin/(YOUR SKIN)/header.tpl
Define a smarty_function just like {jrCore_list... or any other smarty function, its pretty simple once the module structure is in place.
Look for functions marked smarty_function_....... in include.php files for examples, let me know if you get stuck and I'll walk you through it.
so what you end up with is a function that fires from the template eg:
{xxMymodule_default_lang}
That will fire smarty_function_xxMymodule_default_lang() which is a php function.
Next option is to hook into an event which fires when the page loads.
"Events and Listeners"
https://www.jamroom.net/the-jamroom-network/documentation/development/1011/events-and-listeners
and find an event, then fire off a server side function.
Another way to do it, but client side without a module would be to check for a cookie on page load, and if it isn't there redirect via javascript to the detected language, then set a cookie so the user doesnt get redirected next time.