Gearman Workers need to be started separately, so it doesn't really matter where you put them. After you have written the worker code, just start the script from the terminal using
php /path/to/worker/gearman-worker.php
As the script starts, it will register itself with the given server and pick-up any jobs that might be available.
You can read about the Gearman worker here, but notice the important part is the server registration
$worker -> addServer();
Here, calling the function without any arguments will register the worker to a Gearman server running on localhost, but you can make it register to any server on any port by setting these arguments (as specified in the link above).