In this context, there is very little difference. "By the end" means the habit could have been set before the end. Maybe it was already set after two weeks, but he had committed to a three-week period.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.