If you want the same macros to be loaded in all your documents, make a new, empty file, go to Document --> Settings --> LaTeX preamble, add your macros here, and then click the button Save as Document defaults. All new documents you create afterwards will have those same macro definitions in the preamble.
If you want different defaults, I'm not sure what's the best way. You could just make different
.tex files, and
\input the appropriate one in the preamble.
Another option could be to make your own modules. This is described in Help --> Customization, section 5.3. A very simple example is something like this:
#Provides some macros I frequently use
#Author: Some Bloke
Save this as
homework.module, in the
layouts subfolder in your LyX user directory (https://wiki.lyx.org/LyX/UserDir). E.g. on my system, that's in
~/.lyx/layouts. Restart LyX (possibly run Tools --> Reconfigure, but not sure if that's necessary), and in Document --> Settings --> Modules, you should see homework at the bottom of the list.