First I recommend you to red the NesTech.txt (you can get it here: http://nesdev.parodius.com/ndox200.zip).
Background Tiles are defined in the nametable (the nametables are located in the VRAM from $2000 to $3000). The NES has 2 (independend) nametables - altough it has adressing space for 4 (so the 2 nametables are mirrored to the other 2 which makes 4). You specify the current nametable with the PPU control register 1 (which is in NES Memory @ memory location $2000). Then you have to write to this nametable (the numbers of your tiles) where one Byte in the nametable represents 1 tile. You can write to the VRAM with the help of 2 other registers:
The first register is the PPU Adressing register aka $2006. The first byte written to this register specifies the high part, the second byte the low part of a 16-bit adress (in the VRAM). You can now write to this adress in VRAM with register $2007 (write a value to $2007 and this one will be written to the VRAM location specified by the 16-bit adress). After each write to $2007 the adress is incremented (depending on $2000 content -> look in the nestech.txt) with 1 or 32.
Sprite RAM is accessed via 2 other registers - it works the same way as above - only that adresses are only 1 byte in size so you have to write only once to the adress register (you can look up the register in nestech.txt -):)). The format of the data in Sprite RAM is also descriped there.
I hope this helps a bit. Just read the document and you'll see that what i wrote will make sense -):D
If you still have questions - just ask