Yep, you can do that. Of course if his heir turns out to be ambitious or envious (or both) you may have problems. Especially if you own counties in his duchy and he gets the 'desires the county of blahblah penalty'.
What I do frequently in situations where I want to keep counties in a rich duchy without taking the 'too many held duchies' penalty is this: I find a male character in my realm, usually a bit older (45-50, but this depends on the circumstances - for instance, if your ruler is young and/or it'll be many years before the county becomes productive due to conqueror penalties, I may choose a younger individual) who has the Celibate and Content traits. If I can't find one with both, I go with just Celibate. If I can't find somebody matching these criteria at all in my realm, I just invite somebody from another. I then arrange this loyal old celibate character into a marriage with a celibate woman (a bit younger than him, preferably, so she will be likely to outlive him) and then give him the county and duchy I want to get rid of (keeping the rest for myself). He'll usually be happy because of his Content trait in spite of the penalties from you holding the other counties, but if you're worried about that, just give him a gift of 20.0 gold before appointing him to further placate him. You now have a happy vassal who will never produce any children and will probably die in 10-20 years, giving you plenty of time to figure out what you want to do with that piece of land. And when that time's up, you can just repeat the process as necessary, of course.
I actually frequently appoint Celibate men to counts in counties that I want to inherit later, once the religious/foreign culture conqueror penalties have worn off. That way I can just give away my old (poorer) counties once they croak with no heirs, and take the nice, shiny new rich ones for myself.