how to earn a transaction fee for transactions originating from my client
By definition, "transaction fee" is the difference between sum of inputs and sum of outputs. It always goes to the miner.

What you need is to add an output payable to your account.