The offense scores a touchdown, after the play an offensive player is called for an unsportsman conduct penalty that is enforced on the kickoff. The kickoff goes out-of-bounds. Where is the ball placed?
Per Rule 6-2-3, if a kick-off goes out-of-bounds untouched or last touched by the kicking team, it will be placed at a spot 25 yards from the kick-off spot OR at the spot where it goes out-of-bounds, whichever is more advantageous to the receiving team.
So in the situation you pose, the kick-off will be from the kicking team’s 20 yard line so the ball will be placed at the kicking team’s 45 yard line unless it went out of bounds before the 45.
Similarly, if the foul had been on the defense, the kick-off would have been from the 50 yard line and the ball would be placed at the 25 if the kick went out-of-bounds.