Addressing the last part of your question first, the text is below:
Hebrews 1:8-12 (from Psalm 102:25-27) - NASB
But of the Son He says, "YOUR THRONE, O GOD, IS FOREVER AND EVER, AND THE RIGHTEOUS SCEPTER IS THE SCEPTER OF HIS KINGDOM. "YOU HAVE LOVED RIGHTEOUSNESS AND HATED LAWLESSNESS; THEREFORE GOD, YOUR GOD, HAS ANOINTED YOU WITH THE OIL OF GLADNESS ABOVE YOUR COMPANIONS." And, "YOU, LORD, IN THE BEGINNING LAID THE FOUNDATION OF THE EARTH, AND THE HEAVENS ARE THE WORKS OF YOUR HANDS; THEY WILL PERISH, BUT YOU REMAIN; AND THEY ALL WILL BECOME OLD LIKE A GARMENT, AND LIKE A MANTLE YOU WILL ROLL THEM UP; LIKE A GARMENT THEY WILL ALSO BE CHANGED. BUT YOU ARE THE SAME, AND YOUR YEARS WILL NOT COME TO AN END."
Here, the passage is referring generally to properties of God the Son, and not to properties of actions of God the Son. Specifically, it is referring to whether or not God the Son will ever die or cease to exist. At minimum, what this passage is teaching is that the Son will outlast the earth and the heavens.
Saying that the Son will outlast the earth and the heavens does not demand that He will always teach the exact same thing regarding violent behavior, no matter the circumstance. The two things are really not related at all.
Nonetheless, I do not hold such a minimalistic view of verse 27 -- I don't think it is ONLY teaching that the Son will outlast the heavens and the earth. It appears as though the psalmist is appealing to the basic, unchanging nature of God as proof that God the Son will never cease to exist. This would mean that God's basic nature is in some sense unchanging. Given that God initiated time itself, this should not come as a surprise.
So, if He is in fact unchanging in some sense, how are we to understand His apparently temporally changing teachings? If He never changes, how can it be that His actions change?
Simply, He is not His actions.
His actions have properties or attributes that cannot directly be said to apply to Him.
If the Son teaches nonviolence, that does not mean that He Himself is nonviolent. So, if He were to command the humans He has created never to be violent, that in no way means that He Himself is no longer allowed to end people's lives. It would not prohibit Him from being violent, in other words.
So again, He is not His teachings. Therefore, if His teachings change, that does not mean that His inherent nature has changed.
That should clear up the second portion of your question. Now to address the first part of it: Did Jesus preach nonviolence?
There were times when Christ taught that nonviolence was the appropriate path. There were other times, however, when violence was better. To quote the author of Ecclesiastes:
Ecclesiastes 3:1,3,8 (NASB)
There is an appointed time for everything. And there is a time for every event under heaven -- A time to kill and a time to heal; A time to tear down and a time to build up. A time to love and a time to hate; A time for war and a time for peace.
This is Christ's unchanging teaching on the subject. There is a time for the one, and a time for the other.