The words come from a poem by George Herbert called The Elixir. In 1633 as he lay dying Herbert gave a copy of his poetic writings to a friend and asked him to publish them, if he thought, 'it may turn to the advantage of any poor dejected soul'. Many a soul have greatly been advantaged since then, including notably Charles Spurgeon and C S Lewis.
Teach me my God and King,
In all things Thee to see,
And what I do in anything,
To do it as for Thee.
The Elixir is a fabled substance or stone that had the ability to transform base metals into gold.
Not rudely as a beast,
To run into an action,
But still to make thee prepossest,
And give it his perfection
Here Herbert asks not to act like an animal that simply acts out of habit or instinct....not to run hastily and without thought. Rather he says, 'let me deliberately dedicate every action to you before I do it' (Orrick). And may it thus be a 'perfect' action. The thought here is not referring to God's action since throughout the poem he has been addressing God directly, and if that were the case here he would have said, 'your' perfection'. No rather the idea is that when an action is dedicated to God it becomes perfect, or better, complete.
The following verses are equally wonderful and thought provoking. I'll write more on them when I have time. For this and many other of Herbert's poems check out a wonderful book by Professor Jim Orrick, A Year with George Herbert.